kphcdr 1 year ago
parent
commit
717c1fbc1b

+ 34 - 0
app/Mail/ForgetPasswordEmail.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Mail;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Mail\Mailable;
+use Illuminate\Queue\SerializesModels;
+
+class ForgetPasswordEmail extends Mailable
+{
+    use Queueable, SerializesModels;
+
+    public $code;
+    public $subject = "您的找回密码验证码";
+
+    /**
+     * @param $code
+     */
+    public function __construct($code)
+    {
+        $this->code = $code;
+    }
+
+    /**
+     * Build the message.
+     *
+     * @return $this
+     */
+    public function build()
+    {
+        return $this->view('emails.forgetPassword');
+    }
+}

+ 1 - 1
app/Mail/RegisterEmail.php

@@ -12,7 +12,7 @@ class RegisterEmail extends Mailable
     use Queueable, SerializesModels;
 
     public $code;
-
+    public $subject = "您的注册验证码";
     /**
      * @param $code
      */

+ 20 - 14
app/Modules/Mini/Services/EmailService.php

@@ -4,6 +4,7 @@ namespace App\Modules\Mini\Services;
 
 use App\Base\BaseService;
 use App\Exceptions\ClientException;
+use App\Mail\ForgetPasswordEmail;
 use App\Mail\RegisterEmail;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\Mail;
@@ -22,28 +23,33 @@ class EmailService extends BaseService
         }
     }
 
-    public function register($email): bool
+    private function register($email): bool
     {
-        $captcha = Cache::remember("registerCaptcha" . $email, 10, function () {
+        $captcha = Cache::remember("email:registerCaptcha" . $email, 10, function () {
             return rand(100000, 999999);
         });
-//        try {
-        Mail::to($email)->send(new RegisterEmail($captcha));
-//        } catch (\Exception $e) {
-//            logger()->error("邮件发送失败  ". $e->getMessage());
-//            throw new ClientException("邮件发送失败,请稍后再试");
-//        }
+        try {
+            Mail::to($email)->send(new RegisterEmail($captcha));
+        } catch (\Exception $e) {
+            logger()->error("邮件发送失败  " . $e->getMessage());
+            throw new ClientException("邮件发送失败,请稍后再试");
+        }
 
         return true;
     }
 
-    public function forgetPassword($email): bool
-    {
-
-    }
-
-    private function send($email, $source)
+    private function forgetPassword($email): bool
     {
+        $captcha = Cache::remember("email:forgetPasswordCaptcha" . $email, 10, function () {
+            return rand(100000, 999999);
+        });
+        try {
+            Mail::to($email)->send(new ForgetPasswordEmail($captcha));
+        } catch (\Exception $e) {
+            logger()->error("邮件发送失败  " . $e->getMessage());
+            throw new ClientException("邮件发送失败,请稍后再试");
+        }
 
+        return true;
     }
 }

+ 188 - 0
resources/views/emails/forgetPassword.blade.php

@@ -0,0 +1,188 @@
+<div>
+    <includetail>
+        <div style="font:Verdana normal 14px;color:#000;">
+            <div style="position:relative;">
+                <div class="eml-w eml-w-sys-layout">
+                    {{--页眉--}}
+                    <div style="font-size: 0px;">
+                        {{--分割线--}}
+                        <div class="eml-w-sys-line">
+                            <div class="eml-w-sys-line-left"></div>
+                            <div class="eml-w-sys-line-right"></div>
+                        </div>
+                    </div>
+                    {{--以下写正文--}}
+                    <div class="eml-w-sys-content">
+                        {{--以下写正文--}}
+                        <div class="dragArea gen-group-list">
+
+                            {{-- 普通的文本  --}}
+                            <div class="gen-item">
+                                <div class="eml-w-item-block" style="padding: 0px;">
+                                    <div class="eml-w-phase-normal-16">你好,你的找回密码验证码为:</div>
+                                </div>
+                            </div>
+                            {{-- 普通的文本【自定义样式】  --}}
+                            <div class="gen-item">
+                                {{-- padding:行间距 --}}
+                                <div class="eml-w-item-block" style="padding: 0px;">
+                                    <div class="eml-w-phase-normal-16" style="color: red;text-align: center;font-weight:bold;font-size: 20px">{{$code}}</div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                    {{--  署名  --}}
+                    <div class="eml-w-sys-footer">恒久电子商城</div>
+                </div>
+                {{--                <img src="//exmail.qq.com/qy_mng_logic/reportKV?type=NewFeatureNotify0731&amp;itemName=NewFeatureNotify0731" style="width:1px;height:1px;display:none;" onerror="">--}}
+            </div>
+        </div><!--<![endif]-->
+    </includetail>
+</div>
+
+<style>
+    .eml-w .eml-w-phase-normal-16 {
+        color: #2b2b2b;
+        font-size: 16px;
+        line-height: 1.75
+    }
+
+    .eml-w .eml-w-phase-bold-16 {
+        font-size: 16px;
+        color: #2b2b2b;
+        font-weight: 500;
+        line-height: 1.75
+    }
+
+    .eml-w-title-level1 {
+        font-size: 20px;
+        font-weight: 500;
+        padding: 15px 0
+    }
+
+    .eml-w-title-level3 {
+        font-size: 16px;
+        font-weight: 500;
+        padding-bottom: 10px
+    }
+
+    .eml-w-title-level3.center {
+        text-align: center
+    }
+
+    .eml-w-phase-small-normal {
+        font-size: 14px;
+        color: #2b2b2b;
+        line-height: 1.75
+    }
+
+    .eml-w-picture-wrap {
+        padding: 10px 0;
+        width: 100%;
+        overflow: hidden
+    }
+
+    .eml-w-picture-full-img {
+        display: block;
+        width: auto;
+        max-width: 100%;
+        margin: 0 auto
+    }
+
+    .eml-w-sys-layout {
+        background: #fff;
+        box-shadow: 0 2px 8px 0 rgba(0, 0, 0, .2);
+        border-radius: 4px;
+        margin: 50px auto;
+        max-width: 700px;
+        overflow: hidden
+    }
+
+    .eml-w-sys-line-left {
+        display: inline-block;
+        width: 88%;
+        background: #2984ef;
+        height: 3px
+    }
+
+    .eml-w-sys-line-right {
+        display: inline-block;
+        width: 11.5%;
+        height: 3px;
+        background: #8bd5ff;
+        margin-left: 1px
+    }
+
+    .eml-w-sys-logo {
+        text-align: right
+    }
+
+    .eml-w-sys-logo img {
+        display: inline-block;
+        margin: 30px 50px 0 0
+    }
+
+    .eml-w-sys-content {
+        position: relative;
+        padding: 20px 50px 0;
+        word-break: break-all
+    }
+
+    .eml-w-sys-footer {
+        font-weight: 500;
+        font-size: 12px;
+        color: #bebebe;
+        letter-spacing: .5px;
+        padding: 0 0 30px 50px;
+        margin-top: 60px
+    }
+
+    .eml-w {
+        font-family: Helvetica Neue, Arial, PingFang SC, Hiragino Sans GB, STHeiti, Microsoft YaHei, sans-serif;
+        -webkit-font-smoothing: antialiased;
+        color: #2b2b2b;
+        font-size: 14px;
+        line-height: 1.75
+    }
+
+    .eml-w a {
+        text-decoration: none
+    }
+
+    .eml-w a, .eml-w a:active {
+        color: #186fd5
+    }
+
+    .eml-w h1, .eml-w h2, .eml-w h3, .eml-w h4, .eml-w h5, .eml-w h6, .eml-w li, .eml-w p, .eml-w ul {
+        margin: 0;
+        padding: 0
+    }
+
+    .eml-w-item-block {
+        margin-bottom: 10px
+    }
+
+    @media (max-width: 420px) {
+        .eml-w-sys-layout {
+            border-radius: none !important;
+            box-shadow: none !important;
+            margin: 0 !important
+        }
+
+        .eml-w-sys-layout .eml-w-sys-line {
+            display: none
+        }
+
+        .eml-w-sys-layout .eml-w-sys-logo img {
+            margin-right: 30px !important
+        }
+
+        .eml-w-sys-layout .eml-w-sys-content {
+            padding: 0 35px !important
+        }
+
+        .eml-w-sys-layout .eml-w-sys-footer {
+            padding-left: 30px !important
+        }
+    }
+</style>

+ 2 - 49
resources/views/emails/register.blade.php

@@ -10,10 +10,6 @@
                             <div class="eml-w-sys-line-left"></div>
                             <div class="eml-w-sys-line-right"></div>
                         </div>
-                        {{--  LOGO --}}
-                        <div class="eml-w-sys-logo">
-                            <img src="https://rescdn.qqmail.com/node/wwqy/qymng/style/images/sass/independent/welcome_eml_logo.png" style="width: 34px; height: 24px;" onerror="">
-                        </div>
                     </div>
                     {{--以下写正文--}}
                     <div class="eml-w-sys-content">
@@ -26,59 +22,17 @@
                                     <div class="eml-w-phase-normal-16">你好,你的注册验证码为:</div>
                                 </div>
                             </div>
-
-                            {{-- 普通的文本【自定义样式】  --}}
-                            <div class="gen-item">
-                                {{-- padding:行间距 --}}
-                                <div class="eml-w-item-block" style="padding: 10px;">
-                                    <div class="eml-w-phase-normal-16" style="color: red;text-align: center;font-weight:bold"> {{$code}} </div>
-                                </div>
-                            </div>
-
                             {{-- 普通的文本【自定义样式】  --}}
                             <div class="gen-item">
                                 {{-- padding:行间距 --}}
                                 <div class="eml-w-item-block" style="padding: 0px;">
-                                    <div class="eml-w-phase-normal-16" style="color: red;text-align: center;font-weight:bold;font-size: 20px">
-                                        123456
-                                    </div>
+                                    <div class="eml-w-phase-normal-16" style="color: red;text-align: center;font-weight:bold;font-size: 20px">{{$code}}</div>
                                 </div>
                             </div>
-
-                            {{--  一级标题  --}}
-                            <div class="gen-item">
-                                <div class="eml-w-item-block" style="padding: 0px;">
-                                    <div class="eml-w-title-level1">一、通用功能</div>
-                                </div>
-                            </div>
-
-                            {{--  二级标题,以及正文--}}
-                            <div class="gen-item" draggable="false">
-                                <div class="eml-w-item-block" style="padding: 0px 0px 0px 1px;">
-                                    {{--  二级标题--}}
-                                    <div class="eml-w-title-level3">1. 管理后台 “域名管理” 优化</div>
-                                    {{--  二级标题里的小字号正文  --}}
-                                    <div>
-                                        <div class="eml-w-phase-small-normal">
-                                            <p>· 新增“管理记录”,可以查看域名注册、实名审核、续费等记录。</p>
-                                        </div>
-                                    </div>
-                                </div>
-                            </div>
-
-                            {{--显示图片--}}
-                            <div class="gen-item" draggable="false">
-                                <div class="eml-w-item-block" style="padding: 0px;">
-                                    <div class="eml-w-picture-wrap">
-                                        <img src="https://qy-eml-render-1258476243.cos.ap-guangzhou.myqcloud.com/images/sys/202114/pic1%402x.png" class="eml-w-picture-full-img" style="max-width: 100%;" draggable="false" onerror="">
-                                    </div>
-                                </div>
-                            </div>
-
                         </div>
                     </div>
                     {{--  署名  --}}
-                    <div class="eml-w-sys-footer">腾讯企业邮团队</div>
+                    <div class="eml-w-sys-footer">恒久电子商城</div>
                 </div>
                 {{--                <img src="//exmail.qq.com/qy_mng_logic/reportKV?type=NewFeatureNotify0731&amp;itemName=NewFeatureNotify0731" style="width:1px;height:1px;display:none;" onerror="">--}}
             </div>
@@ -171,7 +125,6 @@
     .eml-w-sys-content {
         position: relative;
         padding: 20px 50px 0;
-        min-height: 216px;
         word-break: break-all
     }