Asked  7 Months ago    Answers:  5   Viewed   49 times

I am trying to send email from my php :

$to = 'it@7sisters.in';
    $email_from = "info@7sisters.in";

    $full_name = 'Suraj Hazarika';
    $from_mail = $full_name.'<'.$email_from.'>';



    $subject = "testing sender name";
    $message = "";
    $message .= '
            <p><strong>This is only a test . Please do not reply.</strong><br />
    ';
    $from = $from_mail;

    $headers = "" .
               "Reply-To:" . $from . "rn" .
               "X-Mailer: PHP/" . phpversion();
    $headers .= 'MIME-Version: 1.0' . "rn";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";        
    mail($to,$subject,$message,$headers);

I am following the tutorial PHP E-mail Form Sender Name Instead Of E-mail? but I am still getting the emails with sender name with hostname.

     From                              Date             Subject 
sisters@rsx02.justhost.com  Fri, 11:24 pm       testing sender name
sisters@rsx02.justhost.com  Fri, 11:24 pm       testing sender name

 Answers

87

You only use $from in your Reply-To header. If you want it to be in the From header, you need to set it in the From header.

Put something like this before your mail() command:

$headers .= 'From: ' . $from . "rn";
Wednesday, March 31, 2021
 
kmunky
answered 7 Months ago
47

Please please please don't build your own MIME emails. Use PHPMailer or Swiftmailer, which do almost everything for you. You can replace you entire script with about 5 or 6 lines of code.

And best of all, they'll give you far better error messages/diagnostics than the pathetically stupid mail() function ever will.

Wednesday, March 31, 2021
 
ammezie
answered 7 Months ago
44

Right after your 4 lines that say $email_message .= ... add a line:

$email_from = $full_name.'<'.$email_from.'>';
Friday, July 2, 2021
 
BrunoRamalho
answered 4 Months ago
42

Are your images requested with HTTP or HTTPS?

If so, that's the problem.

HTTPS->HTTP referrals do not leak a Referer Header (HTTP_REFERER).

If you embed a HTTP hosted image in an email that is requested from an HTTPS page, it won't send a referrer. (HTTP pages requesting HTTPS, however, do send a referer).The solution is to embed the image as HTTPS. I've tested it, and sure enough, secure HTTPS images do indeed send the Referrer.

One way Gmail could block the referrer information on loaded images by default is if they used a referrer policy, which is supported on most modern browsers. (As of 2011, they did not implement such a policy.)

See the below screenshot of an embedded image that is generated dynamically with the HTTP REFERER of the request: enter image description here

Wednesday, July 28, 2021
 
Kemrop
answered 3 Months ago
14

use

var_dump($row);

instead of

echo $row;

and if you just want to see the values of the array you can do something like the following

for ($var = 0; $var < sizeof($row); $var++) echo $row[$var].", ";
Saturday, July 31, 2021
 
dimitarvp
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :