1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-28 05:11:39 +08:00
2020-04-21 19:23:20 +08:00

57 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Services\Mailer;
use App\Services\Mailer;
use App\Services\Verification;
class Verify extends Mailer
{
/**
* @param string $email
* @return bool
*/
public function handle($email)
{
try {
$message = $this->manager->createMessage();
$verification = new Verification();
$minutes = 5;
$code = $verification->getSmsCode($email, 60 * $minutes);
$subject = '邮件验证码';
$content = $this->formatContent($code, $minutes);
$count = $message->to($email)
->subject($subject)
->content($content)
->send();
$result = $count > 0;
} catch (\Exception $e) {
$this->logger->error('Send Verify Mail Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
]));
$result = false;
}
return $result;
}
protected function formatContent($code, $minutes)
{
return sprintf('验证码:%s%s 分钟内有效,如非本人操作请忽略。', $code, $minutes);
}
}