mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKit.git
synced 2026-01-15 00:35:08 +08:00
@@ -36,8 +36,8 @@ return [
|
||||
],
|
||||
'app' => [
|
||||
'expire_time' => 30 * 24 * 60 * 60,
|
||||
'prefix_key' => 'token:'
|
||||
]
|
||||
'prefix_key' => 'token:',
|
||||
],
|
||||
],
|
||||
|
||||
// redis 补充配置
|
||||
@@ -57,4 +57,26 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
// 第三方服务
|
||||
'third_party' => [
|
||||
'email' => [
|
||||
'dsn' => 'smtp://account@luxcreo.ai:Qfsd8866@smtp.qiye.aliyun.com:465',
|
||||
'mailer_sender' => 'account@luxcreo.ai', // 发件邮箱
|
||||
'mailer_sender_name' => 'LuxCreo', // 发件人名称
|
||||
],
|
||||
'sms' => [
|
||||
'aliyun' => [
|
||||
'access_key_id' => env('ACCESS_KEY_ID', ''),
|
||||
'access_key_secret' => env('ACCESS_KEY_SECRET', ''),
|
||||
'sign' => '', // 短信签名名称
|
||||
'template_code' => '', // 短信模板CODE
|
||||
],
|
||||
],
|
||||
'storage' => [
|
||||
'oss' => [
|
||||
'access_key_id' => env('ACCESS_KEY_ID', ''),
|
||||
'access_key_secret' => env('ACCESS_KEY_SECRET', ''),
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
62
src/Utils/Service/EmailService.php
Normal file
62
src/Utils/Service/EmailService.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* This file is part of LuxAccountX.
|
||||
*
|
||||
* @link http://124.126.16.154:8888/WebService/LuxAccountX
|
||||
* @document https://lux-software.yuque.com/htnx76/vcm2oc
|
||||
* @contact dongyun.li@luxcreo.ai
|
||||
*/
|
||||
|
||||
namespace Singularity\HDK\Utils\Service;
|
||||
|
||||
use Symfony\Component\Mailer\Mailer;
|
||||
use Symfony\Component\Mailer\Transport;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
/**
|
||||
* 邮箱验证码
|
||||
*/
|
||||
class EmailService
|
||||
{
|
||||
/**
|
||||
* @var \Symfony\Component\Mailer\Mailer
|
||||
*/
|
||||
private Mailer $mailer;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$dsn = config('common.third_party.email.dsn');
|
||||
$transport = Transport::fromDsn($dsn);
|
||||
$this->mailer = new Mailer($transport);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
* @param string $target
|
||||
* @param string $subject
|
||||
* @param string $text
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
|
||||
*/
|
||||
public function sendCode(
|
||||
string $target,
|
||||
string $subject = '',
|
||||
string $text = ''
|
||||
): bool {
|
||||
$from = config('mailer_sender_name') . ' <' . config('mailer_sender') . '>';
|
||||
$email = (new Email())
|
||||
->from(Address::create($from))
|
||||
->to($target)
|
||||
->subject($subject)
|
||||
->text($text);
|
||||
|
||||
$this->mailer->send($email);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user