2015-02-12 207 views
0

我在嘗試發送電子郵件時遇到此問題。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!"; 
} 
+0

'$ mail-> SMTPSecure'在哪裏? – 2015-02-12 06:19:38

+0

[閱讀文檔](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting) – Synchro 2015-02-12 10:51:44

回答

0

如果您與服務提供商例如GoDaddy託管,它不會讓你使用SMTP authentication.Kindly檢查通過。 如果不是,您需要檢查您的端口地址。 首先嚐試在本地主機中使用google smtp。

+0

我試過谷歌smtp,它的工作原理像SMTPAuth = true,ssl 465的魅力。 – user2126081 2015-02-12 06:49:15

+0

http:// stackoverflow。 com/questions/18496650/smtp-connect-failed-message-was-not-sent-mailer-error-smtp-connect-failed – 2015-02-12 06:54:36

+0

閱讀上面的鏈接並尋找php_openssl .... – 2015-02-12 06:54:58

相關問題