mirror of
https://github.com/lsky-org/lsky-pro.git
synced 2025-01-09 04:19:32 +08:00
✨ 增加测试邮件
This commit is contained in:
parent
0e996b579d
commit
8c80e70696
@ -3,11 +3,13 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\Test;
|
||||
use App\Models\Config;
|
||||
use App\Utils;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SettingController extends Controller
|
||||
@ -26,4 +28,14 @@ class SettingController extends Controller
|
||||
Cache::flush();
|
||||
return $this->success('保存成功');
|
||||
}
|
||||
|
||||
public function mailTest(Request $request): Response
|
||||
{
|
||||
try {
|
||||
Mail::to($request->post('email'))->send(new Test());
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
}
|
||||
|
@ -1333,6 +1333,10 @@ select {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(234 179 8 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-yellow-200 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(254 240 138 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-opacity-75 {
|
||||
--tw-bg-opacity: 0.75;
|
||||
}
|
||||
|
@ -118,6 +118,7 @@
|
||||
<input type="hidden" name="mail[mailers][smtp][transport]" value="smtp">
|
||||
|
||||
<div class="text-right">
|
||||
<x-button type="button" id="mail-test" class="bg-yellow-500">测试</x-button>
|
||||
<x-button type="submit">保存更改</x-button>
|
||||
</div>
|
||||
</form>
|
||||
@ -146,6 +147,36 @@
|
||||
toastr[response.data.status ? 'success' : 'error'](response.data.message)
|
||||
});
|
||||
});
|
||||
|
||||
$('#mail-test').click(function () {
|
||||
Swal.fire({
|
||||
title: '请输入接收测试邮件的邮箱',
|
||||
input: 'text',
|
||||
inputValue: '',
|
||||
inputAttributes: {
|
||||
type: 'email',
|
||||
autocapitalize: 'off'
|
||||
},
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确认',
|
||||
showLoaderOnConfirm: true,
|
||||
preConfirm: (value) => {
|
||||
return axios.post('{{ route('admin.settings.mail.test') }}', {
|
||||
email: value,
|
||||
}).then(response => {
|
||||
if (! response.data.status) {
|
||||
throw new Error(response.data.message)
|
||||
}
|
||||
return response.data;
|
||||
}).catch(error => Swal.showValidationMessage(error));
|
||||
},
|
||||
allowOutsideClick: () => !Swal.isLoading()
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
toastr[result.value.status ? 'success' : 'warning'](result.value.message);
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
3
resources/views/emails/test.blade.php
Normal file
3
resources/views/emails/test.blade.php
Normal file
@ -0,0 +1,3 @@
|
||||
<p>
|
||||
您好,这是一封来自 {{ \App\Utils::config(\App\Enums\ConfigKey::SiteName) }} 的测试邮件,当您看到这封邮件后,说明邮件配置正确。如果不是您本人操作,请忽略。
|
||||
</p>
|
@ -84,6 +84,7 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth.admin']], function ()
|
||||
Route::group(['prefix' => 'settings'], function () {
|
||||
Route::get('', [AdminSettingController::class, 'index'])->name('admin.settings');
|
||||
Route::put('save', [AdminSettingController::class, 'save'])->name('admin.settings.save');
|
||||
Route::post('mail-test', [AdminSettingController::class, 'mailTest'])->name('admin.settings.mail.test');
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user