PHP mail goes in spam and inbox

38.8k Views Asked by At

I am using simple PHP mail function to send mail. Here is my code:

sendEmail('[email protected]', 'test subject', 'test body', 'xyz name', '[email protected]', 'HTML');

function sendEmail($to, $subject, $body, $fromName, $from, $format = '')
{
    $headers = '';

    if($format=='HTML')
    {
        $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    }

    $headers .= "From: $fromName <$from>" . "\n";

    $success = mail($to, $subject, $body, $headers, '-f [email protected]');
    return $success;

}

My problem is this when i send more than one (like 10) mail then some mail goes into spam and some in inbox. If script is wrong then all mail should go into spam or if right then all mail into inbox.

Why some mail goes into spam and some in inbox?

while subject, body, message and email(to) is same.

1

There are 1 best solutions below