usedearplugs Posted May 22, 2013 Share Posted May 22, 2013 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 More sharing options...
wright67uk Posted May 22, 2013 Share Posted May 22, 2013 Try $headers = 'From: $emailFrom . "\r\n" . 'Reply-To: ' . $aDifferentEmailAddress . "\r\n" .'X-Mailer: PHP/' . phpversion();$send = mail($emailTo, $subject, $body, $headers);} and see if that helps? Link to comment https://forums.phpfreaks.com/topic/278260-mail-function-from-problem/#findComment-1431502 Share on other sites More sharing options...
wright67uk Posted May 22, 2013 Share Posted May 22, 2013 That should have been 'From: ' .$emailFrom. "/r/n" . Link to comment https://forums.phpfreaks.com/topic/278260-mail-function-from-problem/#findComment-1431519 Share on other sites More sharing options...
usedearplugs Posted May 22, 2013 Author Share Posted May 22, 2013 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]>"... Link to comment https://forums.phpfreaks.com/topic/278260-mail-function-from-problem/#findComment-1431660 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.