李帅

1.邮件发送服务

......@@ -10,6 +10,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Redis;
......@@ -43,6 +44,39 @@ class SendVerificationMessage implements ShouldQueue
$redis->setex($this->email,1800,$code); //过期时间30分钟
Mail::to($this->email)->send(new SendVerifyCode($code));
$api = 'https://api.sendcloud.net/apiv2/mail/send';
$API_USER = 'mofunsky_noreply';
$API_KEY = '8EkR0XnMuJn6V5yQ';
$from = 'noreply@mofunsky.com';
$vars = json_encode(array(
"to" => array($this->email),
"sub" => array(
'%code%' => array($code),
),
));
$param = array(
'api_user' => $API_USER, // 使用api_user和api_key进行验证
'api_key' => $API_KEY,
'from' => $from, // 发信人,用正确邮件地址替代
'fromname' => 'Parlando',
'substitution_vars' => $vars,
'template_invoke_name' => 'parlando_mail_verify',
'subject' => '[Parlando] Register Verify',
'resp_email_id' => 'true'
);
$data = http_build_query($param);
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => $data
));
$context = stream_context_create($options);
$result_json = file_get_contents($api, FILE_TEXT, $context);
Log::channel('daily')->debug($result_json);
}
}
......