Log in

View Full Version : php mail() sending mails to spam folder



hemi519
11-30-2010, 05:03 PM
Hi All,

Iam sending mails from PHP and they are going straight to SPAM folder.How to avoid these and make them to my inbox. this is my code

<?php
$To="ssssssss@gmail.com";

$Subject="U WON 10 crore";

$headers = "From: sss@gmail.com";
$Body="see this image";

if(mail($To,$Subject,$Body,$headers))

{

echo "SUCCESS";

echo ("<a href='$url'\">Back to Website</a>");
}
else
{

echo"message sending failed";

}

?>

Schmoopy
11-30-2010, 06:07 PM
This is a tricky subject, as different mail services have different ways of detecting spam (some are more strict than others).

The fact that the message subject is "U WON 10 crore" makes it look instantly dodgy... you've got to try and make an effort to make the email seem trustworthy.

The message body is also only 3 words, making it look even more suspicious to spam filters. You need to bulk up the message, correct the grammar and try again. Even then, there's no sure way of making your emails not go into the spam folder.

traq
11-30-2010, 08:13 PM
add to the headers: only "From" is required, but add a "reply-to," at least. Put more into the body of the message, as Schmoopy says.

ultimately, however, the only way to be sure it won't go to the spam folder is to have the recipient add the "from" address to their contacts / "trusted" list. good luck with that :)