I use the following script to send emails using PHP
mail("$sendto","$subject","$message","From: $name <$email> \nReply-To: $email \nX-Mailer: PHP $phpver", "-f $email");
My emails sent via PHP are always listed as spam (by yahoo etc). How do I prevent this? I've tried to include various headers (X-Sender etc) and it still makes no difference.
Thanks
Preventing PHP sent mails listed as spam
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
it all involves a delicate set of headers, and more and more often now-a-days, the server you are sending from can play a role too.. Compare the headers of emails that don't get into the trash and those that do.. the large a sample pool you have to look at the more you'll be able to figure out faster.. Then work the differences into your script..
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
my PHP sent emails are never listed as spam and a typical snippet I would use/am using now is this:
so from looking at your post i would suggest removing \nX-Mailer: PHP $phpver from the headers and removing your final parameter (-f $email), i dont even know what it does though 
HTH
Code: Select all
$to = "blah@blah.com";
$subject = "Subject of Blah";
$from = "From: Blah@Blah.co.uk <whatever@blah.co.uk>\r\n";
$replyto = "Reply-To: " . $name . " <" . $email . ">";
$headers = $from . $replyto;
$message = "Loads of blah...";
mail($to, $subject, $message, $headers);HTH