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 webmaster@mysiteExample.com, but it comes out with somemailboxcode123@mysiteExample.com. How can I fix this? Here's a slightly modified version of my code function email($from, $name, $subject, $body){ $emailFrom="webmaster@mysite.com"; $headers = 'From: Web Form <' . $emailFrom . '>' . "\r\n" . 'Reply-To: ' . $aDifferentEmailAddress . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $send = mail($emailTo, $subject, $body, $headers); } Quote Link to comment 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? Quote Link to comment 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" . Quote Link to comment 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 <webmaster@mysite.com>"... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.