PHPMailer:SMTP錯(cuò)誤:無(wú)法連接到SMTP主機(jī)我在幾個(gè)項(xiàng)目中使用過(guò)PHPMailer,但現(xiàn)在我卡住了。它給我錯(cuò)誤:SMTP錯(cuò)誤:無(wú)法連接到SMTP主機(jī)。我試過(guò)從Thunderbird發(fā)送電子郵件,它確實(shí)有效!但不是通過(guò)PHPMailer ......以下是Thunderbird的設(shè)置:服務(wù)器名稱(chēng):mail.exampleserver.com 端口:587 用戶(hù)名:user@exampleserver.com 安全身份驗(yàn)證:無(wú)連接安全性:STARTTLS我在上一個(gè)使用PHPMailer的項(xiàng)目中將這些與服務(wù)器進(jìn)行了比較,它們是:服務(wù)器名稱(chēng):mail.exampleserver2.com 端口:465 用戶(hù)名:user@exampleserver2.com 安全認(rèn)證:無(wú)連接安全性:SSL / TLS我的PHP代碼是: $mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = SMTP_HOST; // SMTP servers
$mail->Port = SMTP_PORT; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = SMTP_USER; // SMTP username
$mail->Password = SMTP_PASSWORD; // SMTP password
$mail->From = MAIL_SYSTEM;
$mail->FromName = MAIL_SYSTEM_NAME;
$mail->AddAddress($aSecuredGetRequest['email']);
$mail->IsHTML(true); // send as HTML哪里錯(cuò)了?
3 回答

鳳凰求蠱
TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超4個(gè)贊
你的問(wèn)題很可能就是這個(gè)問(wèn)題
連接安全性:STARTTLS連接安全性:SSL / TLS
這是兩個(gè)不同的協(xié)議,你使用正確的協(xié)議,無(wú)論你在Thunderbird中使用的是什么,都需要使用。
嘗試設(shè)置變量:
// if you're using SSL
$mail->SMTPSecure = 'ssl';
// OR use TLS
$mail->SMTPSecure = 'tls';
- 3 回答
- 0 關(guān)注
- 916 瀏覽
添加回答
舉報(bào)
0/150
提交
取消