PHP mail goes in spam and inbox [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-13 09:37:35

问题


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

sendEmail('xyz@gmail.com', 'test subject', 'test body', 'xyz name', 'abc@gmail.com', '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 no-reply@xyz.com');
    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:


Use full headers to avoid spam

http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/

Prevent sent emails treated as junk mails using php mail function



来源:https://stackoverflow.com/questions/20416866/php-mail-goes-in-spam-and-inbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!