Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2022-03-30 18:19:43 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2724ddd7d2899b53c8c34feddd60bba53b66fbb1
2724ddd7
1 parent
48f8dd7e
1.邮件发送服务
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletions
app/Jobs/SendVerificationMessage.php
app/Jobs/SendVerificationMessage.php
View file @
2724ddd
...
...
@@ -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
);
}
}
...
...
Please
register
or
login
to post a comment