update: add test send mail

This commit is contained in:
tokumeikoi 2021-11-30 16:23:46 +08:00
parent 05769ea591
commit 30aec3d8e9
4 changed files with 22 additions and 18 deletions

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin;
use App\Http\Requests\Admin\ConfigSave;
use App\Jobs\SendEmailJob;
use App\Services\TelegramService;
use Illuminate\Http\Request;
use App\Utils\Dict;
@ -35,20 +36,19 @@ class ConfigController extends Controller
public function testSendMail(Request $request)
{
$email = $request->session()->get('email');
$subject = 'This is v2board test email';
try {
Mail::raw(
'This is v2board test email',
function ($message) use ($email, $subject) {
$message->to($email)->subject($subject);
}
);
} catch (\Exception $e) {
abort(500, $e->getMessage());
}
$obj = new SendEmailJob([
'email' => $request->session()->get('email'),
'subject' => 'This is v2board test email',
'template_name' => 'notify',
'template_value' => [
'name' => config('v2board.app_name', 'V2Board'),
'content' => 'This is v2board test email',
'url' => config('v2board.app_url')
]
]);
return response([
'data' => true
'data' => true,
'log' => $obj->handle()
]);
}

View File

@ -60,11 +60,15 @@ class SendEmailJob implements ShouldQueue
$error = $e->getMessage();
}
MailLog::create([
$log = [
'email' => $params['email'],
'subject' => $params['subject'],
'template_name' => $params['template_name'],
'error' => isset($error) ? $error : NULL
]);
];
MailLog::create($log);
$log['config'] = config('mail');
return $log;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long