From 08fb2eaf2e83bbcfb9dac3cae63f32961bda68a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=9B=BE=E5=9B=BE?= <209766828@qq.com> Date: Tue, 10 May 2022 07:13:40 +0000 Subject: [PATCH] =?UTF-8?q?update=20app/common/library/Email.php.=20?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=20=E7=94=B1=20smtp=5Fserve?= =?UTF-8?q?r=20=E4=BF=AE=E6=94=B9=E4=B8=BA=20smtp=5Fhost?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/library/Email.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/common/library/Email.php b/app/common/library/Email.php index 73c13771..3388ddc5 100644 --- a/app/common/library/Email.php +++ b/app/common/library/Email.php @@ -37,17 +37,13 @@ class Email //默认配置 protected $config = [ - 'smtp_server' => 'smtp.163.com', // 服务器地址 - 'smtp_port' => 578, // 服务器端口 - 'smtp_user' => 'yourname@163.com', // 邮件用户名 - 'smtp_pass' => '123', // 邮件密码 - 'smtp_name' => '管理员', // 发送邮件显示 ]; /** * 类构造函数 * class constructor. */ + public function __construct() { // 此配置项为数组。 @@ -55,6 +51,8 @@ class Email $this->config = array_merge($this->config, $email); } + //测试 +// var_dump($this->config); // 创建PHPMailer对象实例 $this->mail = new PHPMailer(); $this->mail->CharSet = 'UTF-8'; @@ -65,7 +63,7 @@ class Email $this->mail->SMTPDebug = $this->config['smtp_debug']; $this->mail->SMTPAuth = true; $this->mail->SMTPSecure = 'ssl'; - $this->mail->Host = $this->config['smtp_server']; + $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']); @@ -284,7 +282,7 @@ class Email } $this->config = array_merge($this->config, $config); - $this->mail->Host = $this->config['smtp_server']; + $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']); -- Gitee