PHPMailer:SMTP錯誤:無法連接到SMTP主機我在幾個項目中使用過PHPMailer,但現在我卡住了。它給我錯誤:SMTP錯誤:無法連接到SMTP主機。我試過從Thunderbird發送電子郵件,它確實有效!但不是通過PHPMailer ......以下是Thunderbird的設置:服務器名稱:mail.exampleserver.com 端口:587 用戶名:[email protected] 安全身份驗證:無連接安全性:STARTTLS我在上一個使用PHPMailer的項目中將這些與服務器進行了比較,它們是:服務器名稱:mail.exampleserver2.com 端口:465 用戶名:[email protected] 安全認證:無連接安全性: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哪里錯了?
3 回答
鳳凰求蠱
TA貢獻1825條經驗 獲得超4個贊
你的問題很可能就是這個問題
連接安全性:STARTTLS連接安全性:SSL / TLS
這是兩個不同的協議,你使用正確的協議,無論你在Thunderbird中使用的是什么,都需要使用。
嘗試設置變量:
// if you're using SSL
$mail->SMTPSecure = 'ssl';
// OR use TLS
$mail->SMTPSecure = 'tls';
- 3 回答
- 0 關注
- 931 瀏覽
添加回答
舉報
0/150
提交
取消
