我正在使用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'");*/
?>
有人可以帮助我吗?
答案 0 :(得分:0)
尝试添加:
$mail->isSMTP();
尽管有$mail->SMTPAuth = true;
可能未通过身份验证