From 12bfd887c6c3a31878f6f6239c3f6a8df432e28f Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Thu, 29 Aug 2024 19:09:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/mail/class.phpmailer.php | 2 +- model/mBase.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/library/mail/class.phpmailer.php b/library/mail/class.phpmailer.php index afb71b2..2d70d4a 100644 --- a/library/mail/class.phpmailer.php +++ b/library/mail/class.phpmailer.php @@ -589,7 +589,7 @@ class PHPMailer { /* Retry while there is no connection */ while($index < count($hosts) && $connection == false) { $hostinfo = array(); - if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) { + if(preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) { $host = $hostinfo[1]; $port = $hostinfo[2]; } else { diff --git a/model/mBase.php b/model/mBase.php index 97b9d84..8cb3144 100644 --- a/model/mBase.php +++ b/model/mBase.php @@ -114,7 +114,7 @@ class mBase extends publicBase { * @param string $title 邮件标题 * @param string $content 邮件内容 */ - public static function sendMail($emails, $title, $content) { + public static function sendMail($emails, $title, $content,$attr='') { include_once SERVER_ROOT . '/library/mail/class.phpmailer.php'; $mail_name = array_rand($GLOBALS['notice_qqmail_list']); @@ -122,7 +122,8 @@ class mBase extends publicBase { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = 'smtp.163.com'; - $mail->Port = 465; + $mail->Port = 587; + $mail->SMTPSecure = 'tls'; // 启用 TLS 加密 $mail->Username = $mail_name; $mail->Password = $GLOBALS['notice_qqmail_list'][$mail_name]; $mail->From = $mail_name; @@ -132,6 +133,10 @@ class mBase extends publicBase { $mail->ClearAddresses(); $mail->SetLanguage('en', SERVER_ROOT . '/library/mail/language/'); + if($attr){ + $mail->addAttachment($attr); + } + $mail->FromName = "快乐论文"; foreach($emails as $email) { $mail->AddAddress($email);