I'm building a website that sends and email to a user when he registers.
My code (the gist of it):
<?php
$to = "helloworld@gmail.com";
$subject = "Test mail";
$message = "Hello! \nThis is a simple email message.";
$headers = "From: munged@gmail.com";
$headers .= "\r\nReply-To: munged@gmail.com";
$headers .= "\r\nX-Mailer: PHP/".phpversion();
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
the problem is that when the mail is delivered, the from header remains munged@box123.bluehost.com
, while reply-to gets changed to the specified value.
box123.bluehost.com
is the hostname of the server on which the website is hosted.
So what am I doing wrong? What can I do to get the "From" address the same as the reply-to address?
Is it something I'm doing wrong, or is the web host playing foul?
I had the same Issue, I checked the php.net site. And found the right format.
This is my updated code.
The \r\n should be in double quotes(") itself, the single quotes(') will not work.
I realize this is an old thread, but i had the same problem since i moved to bluehost yesterday. It may not have been the selected answer but i support the bluehost article 206 reply.
I created a valid email in control panel and used it as my From address and it worked.