PHP email doesn't use my FROM field

Here is my code for sending an email:

$headers = "From: MySite.com <support@mysite.com>\r
";
$headers .= "Reply-To: $sender\r
";

$message = wordwrap($message,70);

mail($recipient, $subject, $message, $headers);

However, a tech support dude from my ISP looked in the log files and said the FROM field is actually:

[noparse]recordtest@host363.hostmnster.com[/noparse]

For this reason, some ISPs are blocking the emails I send out. What do I need to add to my code so that the FROM field is really [noparse]support@mysite.com[/noparse]. This sure explains why bounced email messages from the website goto the root email account and not [noparse]support@mysite.com[/noparse]

Thanks!!

Immediate impulse is to say make those \r
's into
's

I believe some hosts prevent you from customizing the “from:” header when sending mail via PHP’s mail() function. I ran into the same problem with some crappy shared hosting company and I was S.O.L.

You can use the -f option, check out the manual. :wink:

There are a few ini settings you can adjust that may let you change the from address, I’ve had to use it on a couple of hosts:

ini_set('sendmail_from', 'me@domain.com');"

Check the PHP manual for the mail command, the comments there are usually quite helpful.

Alex