Jump to content

Mail Function "From" Problem


usedearplugs

Recommended Posts

When sending email using the mail function in PHP, I can't get the from field to show what I want it to. In the header, I set the from email to be [email protected], but it comes out with [email protected]. How can I fix this?

 

Here's a slightly modified version of my code

function email($from, $name, $subject, $body){
    $emailFrom="[email protected]";
    $headers = 'From: Web Form <' . $emailFrom . '>' . "\r\n" .
    'Reply-To: ' . $aDifferentEmailAddress . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    $send = mail($emailTo, $subject, $body, $headers);
}
Link to comment
https://forums.phpfreaks.com/topic/278260-mail-function-from-problem/
Share on other sites

Thank you so much for your reply! I did actually try it that way first (no name, just email address).

 

I could even see how some email clients may show the from differently, but the funny thing is I check the headers in the email and it never even shows the "webmaster" email address anywhere in the email headers.

 

I have also echoed the $headers variable to ensure that it does actually show the proper "From: name <[email protected]>"...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.