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上提交邮件需要SMTP AUTH - >错误:服务器不接受DATA命令:SMTP - >注意:检查连接时是否捕获了EOF
答案 0 :(得分:4)
看起来端口587被阻止了。尝试使用
$mail= new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth= true;
$mail->SMTPSecure= "ssl";
$mail->Host= "smtp.gmail.com";
$mail->Port= 465;.....