Page 1 of 1

Preventing PHP sent mails listed as spam

Posted: Wed Nov 02, 2005 8:20 am
by spartan7
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

Posted: Wed Nov 02, 2005 8:27 am
by feyd
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..

Posted: Wed Nov 02, 2005 9:32 am
by jayshields
my PHP sent emails are never listed as spam and a typical snippet I would use/am using now is this:

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);
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