SMTP - >错误:服务器不接受RCPT

Vin*_*nay 7 phpmailer

 require("phpmailer.inc.php");

class sendmail
{
public static function sendAccountActivateMail($to,$subject,&message)
{
    $flg = false;
    try
{
$mail= new PHPMailer(); 
$mail->IsSMTP(); 
$mail->SMTPAuth= true; 
$mail->SMTPSecure= "tls"; 
$mail->Host= "smtp.gmail.com"; 
$mail->Port= 587; 
$mail->Username= "xxx@mydomain.com"; 
$mail->Password= "xxxxxx"; 
$mail->AddReplyTo("info@mydomain.com"); 
$mail->From= "info@mydomain.com"; 
$mail->FromName= "Website"; 
$mail->Subject= $subject; 
$mail->WordWrap= 50; 
$mail->Body = $message; 
$mail->AddAddress($to); 
$mail->Send(); 
}
catch(Exception $e)
    {
        $flg = false;
    }
    return $flg;
}
}
Run Code Online (Sandbox Code Playgroud)

试图通过phpmailer用smtp发送邮件.打开调试给我错误:

SMTP - >错误:服务器不接受RCPT:550端口587上的邮件提交需要SMTP AUTH SMTP - >服务器不接受ERROR:DATA命令:SMTP - >注意:检查是否已连接EOF

小智 5

看起来 587 端口被阻止了。尝试使用

$mail= new PHPMailer(); 
$mail->IsSMTP(); 
$mail->SMTPAuth= true; 
$mail->SMTPSecure= "ssl"; 
$mail->Host= "smtp.gmail.com"; 
$mail->Port= 465;.....
Run Code Online (Sandbox Code Playgroud)