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 = "abc@gmail.com";
                            
                
                $fromname = "";

                $random_hash = md5(date('r', time()));
        //define the headers we want passed. Note that they are separated with \\r\

        $headers = "MIME-Version: 1.0\
";
        $headers .= "Content-type: text/html; charset=iso-8859-1\\r\
"; 
//        $headers .= "boundary=\\"PHP-alt-".$random_hash."\\"\\r\
";
        $headers .= "X-Priority: 3\\r\
";
                $header .= "Reply-To: No Reply <no-reply@abc.org>\\r\
"; 
                $headers .= "Return-Path:<no-reply@abc.org>\\r\
";
        $headers .= "X-MSMail-Priority: Normal\\r\
";
        $headers .= "X-Mailer: php\\r\
"; 
                $headers .= 'From: ' . $fromname . '<' . $mailfrom . '>' . "\\r\
";


                $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;
        }else{
            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?

See: http://www.mxtoolbox.com/

Yes i tried but its going in spam.
what should i do:eek:

thanks, that was helpful. in many server responses. one came blacklist. the website says ‘we notice you are blacklisted’