我在尝试发送电子邮件时收到此信息。
Connection: opening to smtp.163.com:25, t=300, opt=array ()
Connection: opened
SERVER -> CLIENT: 220 163.com Anti-spam GT for Coremail System (163com[20141201])
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-mail250-PIPELINING250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2Ur83fsGUCa0xDrUUUUj250-STARTTLS250 8BITMIME
CLIENT -> SERVER: AUTH LOGIN
SERVER -> CLIENT: 334 dXNlcm5hbWU6
CLIENT -> SERVER: xxx
SERVER -> CLIENT: 334 UGFzc3dvcmQ6
CLIENT -> SERVER: xxx=
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 Bye
Connection: closed<br>
SMTP connect() failed.
Mailer Error: SMTP connect() failed.
代码:
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = "smtp.mydomain.com";
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = "user@mydomain.com";
$mail->Password = "xxxxxxxx";
$mail->setFrom('user@xxx.com', 'user');
$mail->addAddress('user@xxx.com', 'user');
$mail->Subject = 'PHPMailer SMTP test';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
答案 0 :(得分:0)
如果您正在托管像godaddy这样的服务提供商,它将不允许您使用SMTP身份验证。请仔细检查。 如果没有,您需要检查您的端口地址。 首先尝试在您的localhost中使用google smtp。