我在嘗試發送電子郵件時遇到此問題。PHPmailer SMTP連接()失敗
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 = "[email protected]";
$mail->Password = "xxxxxxxx";
$mail->setFrom('[email protected]', 'user');
$mail->addAddress('[email protected]', '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!";
}
'$ mail-> SMTPSecure'在哪裏? – 2015-02-12 06:19:38
[閱讀文檔](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting) – Synchro 2015-02-12 10:51:44