php mail going in spam
Hi, i have tried everything i can find on net to make my script not getting into spam but its not working, i tried on google and hotmail too. what should i do, maybe i m missing something. here is my code
$to = "email@example.com";
$fromname = "";
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
// $headers .= "boundary=\"PHP-alt-".$random_hash."\"\r\n";
$headers .= "X-Priority: 3\r\n";
$header .= "Reply-To: No Reply <firstname.lastname@example.org>\r\n";
$headers .= "Return-Path:<email@example.com>\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-Mailer: php\r\n";
$headers .= 'From: ' . $fromname . '<' . $mailfrom . '>' . "\r\n";
$subject = "United!";
//$subject = html_entity_decode($subject, ENT_QUOTES);
$message = html_entity_decode($body, ENT_QUOTES);
if(!mail($to, $subject, $message, $headers, "-f $mailfrom"))
echo "Mail is not sent for user id = ".$user_id;
echo "Mail is sent for user id = ".$user_id;
"no-reply" is a spam-bait email address. Other than that I didn't spot anything at a cursory glance. If your server is blacklisted there's nothing you can do short of directly whitelisting. I would recommend using the phpMailer class rather than the native php mail function both for security and to get the headers of the email right, which is difficult.
In brief though there are two ways to be labeled spam. 1, get blacklisted. 2. get a header or two wrong. 2 in testing can cause 1 unfortunately. Spam filters are notoriously fickle, and even Fortune 500 businesses who do bulk emails run afoul of them from time to time.
i did tried with subscribe thing too instead of no-reply but didn't work
What's in the body of the e-mail?
If there's a lot of HTML, images and little actual content, that might make Google/ Hotmail think it's spam.
If you send it with a plain text body instead, does the mail arrive properly?
What server is the email being sent on, and has the IP address of that server been blacklisted?
Yes i tried but its going in spam.
Originally Posted by Immerse
what should i do:eek:
thanks, that was helpful. in many server responses. one came blacklist. the website says 'we notice you are blacklisted'
Originally Posted by jonirvine