【发布时间】:2016-02-17 04:21:29
【问题描述】:
<?php
require("class.phpmailer.php");
require("class.smtp.php");
require("class.pop3.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.mail.yahoo.com"; // specify main and backup server
$mail->SMTPSecure = "SSL";
$mail->SMTPKeepAlive = true;
$mail->Port = "587";
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPDebug = 1;
$mail->Username = "abc@yahoo.com"; // SMTP username
$mail->Password = "xyz"; // SMTP password
$mail->From = "abc@yahoo.com";
$mail->FromName = "Prashant kumar";
$mail->AddAddress("pqr@gmail.com", "Yogesh"); // name is optional
$mail->AddReplyTo("mno@gmail.com", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
从最近 2 天开始尝试,得到错误为
SMTP -> 错误:服务器未接受 AUTH:530 5.7.0 必须先发出 STARTTLS 命令
SMTP 错误:无法验证。无法发送消息。
邮件程序错误:SMTP 错误:无法验证。
已经在 stackoverflow 和其他网站上看到了所有可能的问题。 已将 SMTPSecure 和 Port 更改为所有可能的值。 也试过gmail服务器和outlook服务器。 将 SMTPsecure 更改为 STARTTLS 和 TLS 也使用各自的端口。 还删除了 SMTPAuth 行。 尝试了我通过网络找到的所有可能的灵魂。
这是因为我想在我的本地主机上运行它吗? (我在 Windows 8 64 位中使用 XAMPP)
【问题讨论】: