Commit 430e09f8 by 杨树贤

对接正式的邮箱

parent 26f30dfa
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Requests\UserRegister;
use App\Http\Services\UserService;
use App\Mail\SendCode;
use App\Models\UserModel;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
......@@ -195,8 +196,7 @@ class AuthApiController extends Controller
if (!$existEmail) {
return $this->setError('This email is not registered');
}
break;
break;
}
......@@ -209,12 +209,8 @@ class AuthApiController extends Controller
Redis::set($redisKey, $code);
Redis::expire($redisKey, 120);
$subject = config('mail.from.name');
$msg = 'Email Code:' . $code . '.';
return $this->setSuccessData($code);
Mail::raw($msg, function ($message) use ($email, $subject) {
$message->to($email)->subject($subject);
});
// return $this->setSuccessData($code);
Mail::to($email)->send(new SendCode($type, $code));
//错误处理
if (count(Mail::failures())) {
return $this->setError('Email code send failed');
......
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class SendCode extends Mailable
{
use Queueable, SerializesModels;
public $type;
public $code;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($type,$code)
{
$this->type = $type;
$this->code = $code;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('emails.code');
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<div style="padding: 100px">
<div>
<img style="width: 25%;" src="https://img.ichunt.com/images/ichunt/202211/22/c0a944d0d89fde3ba67477369eac1bb2.png">
</div>
@if($type=='register')
<div style="margin-top: 50px">
<p>Hi!</p>
<p>You are registering an account with us.</p>
<p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p>
</div>
@endif
@if($type=='update_email')
<div style="margin-top: 50px">
<p>Hi!</p>
<p>You are modifying your email address.</p>
<p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p>
</div>
@endif
@if($type=='reset_password')
<div style="margin-top: 50px">
<p>Hi!</p>
<p>You are trying to reset your password.</p>
<p>You can enter this code on SEMOUR website:</p>
<span style="font-size: 20px"><strong>{{$code}}</strong></span>
<p>If this was not you, please let us know at INFO@semour.com</p>
</div>
@endif
</div>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment