我在本地计算机上尝试了下面的代码并且工作正常,但是当我在雅虎小企业上托管它时,它一直给出“SMTP connect()失败”。 我该怎么办?
$mail = new PHPMailer();
$body = $message;
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.bizmail.yahoo.com"; //Outgoing mail (SMTP) server
$mail->Port = 465;
$mail->Username = "myadminmail@mydomain.net";
$mail->Password = "mypassword";
$mail->SMTPSecure = 'tls';
$mail->SetFrom('myadminmail@mydomain.net', 'name',false);
$mail->Subject = $subject;
$mail->AltBody = "Any message.";
$mail->MsgHTML($body);
$address = $to;
$mail->AddAddress($address, $name);
if(!$mail->Send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Mailer Sent: ' ;
}
答案 0 :(得分:0)
好的,谢谢大家,我通过删除这一行来让它工作 $ MAIL-> IsSMTP();
答案 1 :(得分:0)
更改行:
$mail->IsSMTP();
有:
$mail->isMail(true);
答案 2 :(得分:0)
这对我有用:
$mail->SMTPDebug = 1;
$mail->isMail(true);
$mail->SMTPSecure = "ssl";
$mail->Port = 587;
$mail->Host = "smtp.bizmail.yahoo.com"; // SMTP server
然后,您必须登录您的Yahoo帐户,然后点击此链接:
https://login.yahoo.com/account/security#other-apps
激活"允许安全性较低的应用程序"。