From 9126f3bad7137bcf91901775a433cb9c4ca28a70 Mon Sep 17 00:00:00 2001 From: Ying Date: Mon, 19 Jun 2023 18:28:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/view/index/basecfg.html | 1 - app/common/driver/notice/EmailDriver.php | 31 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/admin/view/index/basecfg.html b/app/admin/view/index/basecfg.html index bf17b94..d717267 100644 --- a/app/admin/view/index/basecfg.html +++ b/app/admin/view/index/basecfg.html @@ -382,7 +382,6 @@ -
diff --git a/app/common/driver/notice/EmailDriver.php b/app/common/driver/notice/EmailDriver.php index c8fcd9f..4a1b4cb 100644 --- a/app/common/driver/notice/EmailDriver.php +++ b/app/common/driver/notice/EmailDriver.php @@ -211,14 +211,29 @@ class EmailDriver */ public function testEmail(array $config = []): bool { - $this->config = array_merge($this->config, $config); - $this->mail->Host = $this->config['smtp_host']; - $this->mail->Port = $this->config['smtp_port']; - $this->mail->Username = $this->config['smtp_user']; - $this->mail->Password = trim($this->config['smtp_pass']); - $this->mail->SetFrom($this->config['smtp_user'], $this->config['smtp_name']); - if (!$this->address($config['smtp_test'])->Subject("测试邮件")->MsgHTML("如果您看到这封邮件,说明测试成功了!")->send()) { - throw new Exception($this->mail->ErrorInfo); + $mail = new PHPMailer(); + $mail->CharSet = 'UTF-8'; + $mail->IsSMTP(); + $mail->SMTPAuth = true; + $mail->SMTPSecure = 'ssl'; + $mail->SMTPOptions = array( + 'ssl' => array( + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true + ) + ); + + $mail->Host = $config['smtp_host']; + $mail->Port = $config['smtp_port']; + $mail->Username = $config['smtp_user']; + $mail->Password = trim($config['smtp_pass']); + $mail->SetFrom($config['smtp_user'], $config['smtp_name']); + $mail->Subject = "测试邮件"; + $mail->MsgHTML("如果您看到这封邮件,说明测试成功了!"); + $mail->addAddress($config['smtp_test']); + if (!$mail->send()) { + throw new Exception($mail->ErrorInfo); } return true;