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);