【发布时间】:2013-12-15 15:05:02
【问题描述】:
我有这个 PHPMailer:https://github.com/PHPMailer/PHPMailer/
我的代码是这样的:
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'kms-play.it'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'noreply@kms-play.it'; // SMTP username
$mail->Password = 'pass'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'noreply@kms-play.it';
$mail->FromName = 'KMS-Play';
$mail->addAddress('evolutio@kms-play.it', 'Lars Mehrhoff'); // Add a recipient
#$mail->WordWrap = 50; // Set word wrap to 50 characters
#$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
#$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
#$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.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
错误是:
2013-12-15 15:02:23 客户端 -> 服务器:EHLO local.kms-play.it 2013-12-15 15:02:23 客户端 -> 服务器:STARTTLS 2013-12-15 15:02 :23 SMTP 错误:STARTTLS 命令失败:502 5.5.1 错误:命令未实施 2013-12-15 15:02:23 CLIENT -> SERVER: QUIT SMTP connect() 失败。无法发送邮件。Mailer 错误:SMTP 连接()失败。
【问题讨论】:
-
您确定
kms-play.it支持TLS 连接? -
通过问题标题,我虽然 PHPMailer 宣布服务关闭。
-
如果没有 TLS,它会说:
2013-12-15 15:10:33 CLIENT -> SERVER: EHLO local.kms-play.it 2013-12-15 15:10:33 CLIENT -> SERVER: AUTH LOGIN 2013-12-15 15:10:33 SMTP ERROR: AUTH command failed: 535 5.7.8 Error: authentication failed: Invalid authentication mechanism 2013-12-15 15:10:33 CLIENT -> SERVER: QUIT SMTP connect() failed. Message could not be sent.Mailer Error: SMTP connect() failed. -
使用test-smtp.com测试你的smtp服务器。
-
我也想试试swiftmailer.org,你可能会做得更好。 PHPMailer 说它支持“使用 LOGIN、PLAIN、NTLM 和 CRAM-MD5 机制的 SMTP 身份验证”,但是在这种情况下,它似乎无法与服务器就 AUTH 机制达成一致。我希望它用不同的方法再尝试几次,但一次尝试就失败了。我也找不到任何方法来指定要使用的 AUTH 方法 - 所以你可以尝试它们,直到一个工作。