Browse Source

1,修复发送邮件验证问题。

magicblack 5 years ago
parent
commit
8895b060b4
2 changed files with 13 additions and 26 deletions
  1. 4 22
      application/common.php
  2. 9 4
      application/common/model/User.php

+ 4 - 22
application/common.php

@@ -389,6 +389,10 @@ function mac_send_mail($to,$title,$body,$conf=[])
     $title =  View::instance()->display($title);
     $body =  View::instance()->display($body);
 
+    if(!empty($conf)){
+        $config = $conf;
+    }
+
     $cp = 'app\\common\\extend\\email\\' . ucfirst($GLOBALS['config']['email']['type']);
     if (class_exists($cp)) {
         $c = new $cp;
@@ -397,28 +401,6 @@ function mac_send_mail($to,$title,$body,$conf=[])
     else{
         return ['code'=>991,'msg'=>'未找到该邮件发送方式'];
     }
-
-
-    if(!empty($conf)){
-        $config = $conf;
-    }
-    $mail = new \phpmailer\src\PHPMailer();
-    //$mail->SMTPDebug = 2;
-    $mail->isSMTP();
-    $mail->CharSet = "UTF-8";
-    $mail->Host = $config['host'];
-    $mail->SMTPAuth = true;
-    $mail->Username = $config['username'];
-    $mail->Password = $config['password'];
-    $mail->SMTPSecure = 'tls';
-    $mail->Port = $config['port'];
-    $mail->setFrom(  $config['username'] , $config['nick'] );
-    $mail->addAddress($to);
-    $mail->isHTML(true);
-    $mail->Subject = $title;
-    $mail->Body    = $body;
-    unset($config);
-    return $mail->send();
 }
 
 function mac_check_back_link($url)

+ 9 - 4
application/common/model/User.php

@@ -610,6 +610,10 @@ class User extends Base
         }
         //msg_type  1绑定2找回3注册
         $stime = strtotime('-5 min');
+        if($param['ac']=='email' && intval($GLOBALS['config']['email']['time'])>0){
+            $stime = strtotime('-'.$GLOBALS['config']['email']['time'].' min');
+        }
+
         $where=[];
         $where['user_id'] = $GLOBALS['user']['user_id'];
         $where['msg_time'] = ['gt',$stime];
@@ -647,7 +651,7 @@ class User extends Base
         $r=0;
 
         $stime = strtotime('-5 min');
-        if($param['ac']=='email' && !intval($GLOBALS['config']['email']['time'])>0){
+        if($param['ac']=='email' && intval($GLOBALS['config']['email']['time'])>0){
             $stime = strtotime('-'.$GLOBALS['config']['email']['time'].' min');
         }
         $where=[];
@@ -661,9 +665,10 @@ class User extends Base
         $res_msg= ',请重试';
         if($param['ac']=='email'){
             $title = $GLOBALS['config']['email']['tpl']['user_'.$type_flag.'_title'];
-            $body = $GLOBALS['config']['email']['tpl']['user_'.$type_flag.'_body'];
+            $msg = $GLOBALS['config']['email']['tpl']['user_'.$type_flag.'_body'];
             View::instance()->assign(['code'=>$code]);
-            $res_send = mac_send_mail($to, $title, $body);
+            $msg =  View::instance()->display($msg);
+            $res_send = mac_send_mail($to, $title, $msg);
             $res_code = $res_send['code'];
             $res_msg = $res_send['msg'];
         }
@@ -674,7 +679,7 @@ class User extends Base
             $res_code = $res_send['code'];
             $res_msg = $res_send['msg'];
         }
-
+        
         if($res_code==1){
             $data=[];
             $data['user_id'] = $GLOBALS['user']['user_id'];