PHPMailer 发送到 office.com 中的垃圾文件夹

PHPMailer send to junk folder in office.com

我正在使用 PHPMailer,它会将邮件发送到 office.com 中的垃圾文件夹 如何使用 PHPMailer 将邮件发送到收件箱。我想尽快完成这部分,但找不到任何帮助。

下面是我的代码。

<?php
require("email/class.phpmailer.php");

$mail = new PHPMailer(); 

$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Host       = "mail.google.com"; // sets the SMTP server
$mail->CharSet = "utf-8";
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "abc@gmail.com"; // enter your email address
$mail->Password   = "*****";        //enter your password





$webmaster_email = 'xyz@amatheon-agri.com'; //Reply to this email ID
$email= 'xyz@amatheon-agri.com';  // Recipients email ID
$name= 'Test Name'; // Recipient's name

$mail->From = $webmaster_email;
$mail->FromName = 'test';
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,'test');
$mail->WordWrap = 50; // set word wrap

/*$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment
$mail->IsHTML(true); // send as HTML*/

$mail->Subject = 'Test Mail1';
$mail->Body = 'message'; //HTML Body
$mail->AltBody = 'body'; //Text Body

if(!$mail->Send())
{
    echo "Mailer Error: " . $mail->ErrorInfo;
}

else
{
    echo "<h2 align='center'>"."Your Suggestions has been sent to"." ".$name." "."having email"." ".$email."</h2>";
}
//$version= 0;
//echo $final;

/*$suggest= mysqli_query($con,"UPDATE sent_proposals SET In_Discussion = 1, accepted = NULL,declined = NULL WHERE proposal_id= '$proposal_id'");*/

?>

有人能帮帮我吗?

尝试添加:

$mail->isSMTP();

尽管 $mail->SMTPAuth = true; 它可能未通过身份验证