为什么sendmail(ubuntu)+邮件功能(php)发送到SPAM文件夹(gmail)

时间:2017-03-10 02:28:44

标签: sendmail

此代码用于发送邮件但不幸的是邮件转到垃圾邮件文件夹(仅限gmail)。 php代码是

$from = "Test <testFromEmail@gmail.com>"; 
 $headers  = "From: $from \n";
    $headers .= "Cc: $from\n"; 
    $headers .= "X-Sender: $from \n";
    $headers .= 'X-Mailer: PHP/' . phpversion();
    $headers .= "X-Priority: 1\n"; // Urgent message!
    $headers .= "Return-Path: $from \n"; // Return path for errors
    $headers .= "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

$to      = 'TestToEmail@gmail.com';
$subject = 'subject';
$message = 'content';

if ( mail($to,$subject,$message,$headers) ) {
   echo "The email has been sent!";
   } else {
   echo "The email has failed!";
}

我是否需要添加或修改任何缺失的功能来解决此问题

0 个答案:

没有答案