在我的頁面上,我有一個使用 PHP Mailer 的聯(lián)系表格。一開始,僅出于測試目的,我將其與我的 Gmail 帳戶一起使用。一切都像一個魅力。然后我決定將電子郵件服務(wù)從 Gmail 更改為來自我的托管服務(wù)提供商的服務(wù)。然后問題就開始了。每次我嘗試發(fā)送電子郵件時,都會發(fā)生異常:2020-05-13 20:53:44 CLIENT -> SERVER: STARTTLS2020-05-13 20:53:44 SERVER -> CLIENT: 220 ready for tlsSMTP Error: Could not connect to SMTP host.2020-05-13 20:53:44 CLIENT -> SERVER: QUIT2020-05-13 20:53:44 SERVER -> CLIENT: 454 TLS connection failed: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure (#4.3.0)2020-05-13 20:53:44 SMTP ERROR: QUIT command failed: 454 TLS connection failed: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure (#4.3.0)這是我發(fā)送電子郵件的代碼:<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\SMTP; require 'PHPMailer.php'; require 'SMTP.php'; require 'Exception.php'; class Mailer { private $mail; public function __construct($host, $user, $password, $port = 587) { $this->mail = new PHPMailer(); try { $this->mail->SMTPDebug = SMTP::DEBUG_SERVER; $this->mail->CharSet = "UTF-8"; $this->mail->isSMTP(); $this->mail->Host = $host; $this->mail->SMTPAuth = true; $this->mail->SMTPSecure = 'ssl'; $this->mail->Username = $user; $this->mail->Password = $password; $this->mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $this->mail->Port = $port; } catch(Exception $e) { echo "Exception: " . $e; } }我想我在 TLS/SSL 方面錯誤地配置了 PHP Mailer,因為我對此很新手。我的網(wǎng)頁使用 TLS 1.3 加密可能是一個權(quán)宜之計
1 回答

青春有我
TA貢獻(xiàn)1784條經(jīng)驗 獲得超8個贊
這是一個提示,如果有效,請不要忘記投票以加強(qiáng)。讓我們?nèi)ピO(shè)置...
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => false
)
);
請記住,這是一種可以立即起作用的姑息解決方案,但我建議調(diào)查問題。另一個細(xì)節(jié)有時會使用端口 465 和 587 進(jìn)行測試!
$mail->Port = "587";
$mail->SMTPSecure = "tls";
另一件事我不明白......為什么我要使用$ this->mail->SMTPSecure兩次?
$this->mail->SMTPSecure = 'ssl';
$this->mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
- 1 回答
- 0 關(guān)注
- 183 瀏覽
添加回答
舉報
0/150
提交
取消