8
 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;
}
}

尝试使用 smtp 通过 phpmailer 发送邮件。打开调试给我错误:

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

4

1 回答 1

5

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

$mail= new PHPMailer(); 
$mail->IsSMTP(); 
$mail->SMTPAuth= true; 
$mail->SMTPSecure= "ssl"; 
$mail->Host= "smtp.gmail.com"; 
$mail->Port= 465;.....
于 2014-06-05T18:32:53.160 回答