SMTP connect()失败的phpmailer [英] SMTP connect() failed phpmailer
本文介绍了SMTP connect()失败的phpmailer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->SMTPDebug = 1; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mail.yahoo.com'; // Specify main and backup SMTP servers
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'myemail'; // SMTP username
$mail->Password = 'mypass'; // SMTP password
// $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = 'myemail@yahoo.com';
$mail->FromName = 'abc';
$mail->addAddress('abc@abc.com'); // Name is optional
//$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;
} else {
echo 'Message has been sent';
}
我也尝试过gmail,但它一直给我错误SMTP connect()失败.
I have tried gmail also but it keeps giving me error SMTP connect() failed.
这是错误
2015-05-16 07:28:09 CLIENT -> SERVER: EHLO localhost
2015-05-16 07:28:09 CLIENT -> SERVER: AUTH LOGIN
2015-05-16 07:28:10 CLIENT -> SERVER: bWF0ZWVuX3VsX2hhcUB5YWhvby5jb20=
2015-05-16 07:28:10 CLIENT -> SERVER: c2hhaGlkYWZyaWRpMW1hcmNoMTk5MQ==
2015-05-16 07:28:11 SMTP ERROR: Password command failed: 501 Syntax error in arguments
2015-05-16 07:28:11 SMTP Error: Could not authenticate.
2015-05-16 07:28:11 CLIENT -> SERVER: QUIT
2015-05-16 07:28:11 SMTP connect() failed.
无法发送消息.
邮件程序错误:SMTP connect()失败.
Mailer Error: SMTP connect() failed.
推荐答案
您应该真正阅读故障排除指南说-这就是在错误输出中包含指向它的链接的原因.设置SMTPDebug = 2
,这样您就可以查看服务器上的内容,并且很可能会告诉您问题所在.
You should really read what the troubleshooting guide says - that's why the link to it is included in the error output. Set SMTPDebug = 2
so you can see what the server says and it will probably tell you what's wrong.
这篇关于SMTP connect()失败的phpmailer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文