Forráskód Böngészése

Weenier utc项目部署 0625

wesmiler 3 éve
szülő
commit
e60477ef05
1 módosított fájl, 7 hozzáadás és 35 törlés
  1. 7 35
      app/Services/EmailService.php

+ 7 - 35
app/Services/EmailService.php

@@ -88,48 +88,20 @@ class EmailService extends BaseService
             $code = rand(100000, 999999);
             $template = str_replace('{code}', $code, $template);
 
-            var_dump($this->config);
-            Mail::send('emails.index',['title'=> $title,'template'=> $template], function($mail) use($email, $template){
-                $mail->from($this->config['username'],'UTC');
-                $mail->subject($template);
-                $mail->to($email);
+            // 上锁
+            RedisService::set($cacheKey.'_lock', ['email'=> $email, 'code'=> $code, 'date'=> date('Y-m-d H:i:s')], rand(5, 10));
+            Mail::send('emails.index',['title'=> $title,'template'=> $template], function($mail) use($email, $title){
+                $mail->from($this->config['username'],'UTC'); // 发送者
+                $mail->subject($title);  // 标题
+                $mail->to($email);  // 接受者
             });
             $error = Mail::failures();
             if (!$error) {
+                RedisService::set($cacheKey, ['email'=> $email, 'code'=> $code, 'date'=> date('Y-m-d H:i:s')], 300);
                 return true;
             }
 
             return false;
-
-            // 邮件服务
-            $mail = new PHPMailer(true);
-            $mail->CharSet ="UTF-8";                                         //设定邮件编码
-            $mail->SMTPDebug = 0;                                            //调试模式输出:0 不输出,2 输出
-            $mail->Timeout = 10;                                            //超时
-            $mail->Mailer = 'SMTP';
-//            $mail->isSendmail();                                                 //使用SMTP
-            $mail->Host = $this->config['host'];                                     // SMTP服务器:以QQ为例
-            $mail->SMTPAuth = true;                                          // 允许 SMTP 认证
-            $mail->Username = $this->config['username'];                     // SMTP用户名: 即发送方的邮箱
-            $mail->Password = $this->config['password'];                     // SMTP授权码: 即发送方的邮箱授权码
-            $mail->SMTPSecure = isset($this->config['mail_source']['value'])? $this->config['mail_source']['value'] : 'tls';                                       // 允许 TLS 或者ssl协议
-            $mail->Port = $this->config['port'];                                               // 服务器端口: 25 或者465 或者587 具体要看邮箱服务器支持
-
-            RedisService::set('mailer', $this->config, 600);
-            // 上锁
-            RedisService::set($cacheKey.'_lock', ['email'=> $email, 'code'=> $code, 'date'=> date('Y-m-d H:i:s')], rand(5, 10));
-
-            // 设置发送信息参数
-            $mail->setFrom($this->config['username'], "UTC交易平台");   //发件人:邮箱与用户名
-            $mail->addAddress($email, 'Mailer');            //收件人
-            $mail->isHTML(true);     //是否以HTML文档格式发送  发送后客户端可直接显示对应HTML内容
-            $mail->Subject = $title;        //邮件标题
-            $mail->Body    = $template;     //邮件内容
-            $mail->AltBody = "您的验证码是:{$code}";       //邮件内容:如果邮件客户端不支持HTML则显示此内容//*/
-            $mail->send();
-            RedisService::set($cacheKey, ['email'=> $email, 'code'=> $code, 'date'=> date('Y-m-d H:i:s')], 300);
-
-            return true;
         } catch (\Exception $exception){
             $this->error = $exception->getMessage();
             return false;