Added option to test SMTP setup

This commit is contained in:
Julian Prieber 2023-03-13 19:49:30 +01:00
parent b9c0b38260
commit 811e56178b
4 changed files with 39 additions and 0 deletions

View File

@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Hash;
use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Events\Registered;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Mail;
use GeoSot\EnvEditor\Controllers\EnvController; use GeoSot\EnvEditor\Controllers\EnvController;
use GeoSot\EnvEditor\Exceptions\EnvException; use GeoSot\EnvEditor\Exceptions\EnvException;
@ -92,6 +93,23 @@ public function users(Request $request)
return view('panel/users', $data); return view('panel/users', $data);
} }
// Send test mail
public function SendTestMail(Request $request)
{
try {
$userId = auth()->id();
$user = User::findOrFail($userId);
Mail::send('auth.test', ['user' => $user], function ($message) use ($user) {
$message->to($user->email)
->subject('Test Email');
});
return redirect()->route('showConfig')->with('success', 'Test email sent successfully!');
} catch (\Exception $e) {
return redirect()->route('showConfig')->with('fail', 'Failed to send test email. Please try again later.');
}
}
//Block user //Block user
public function blockUser(request $request) public function blockUser(request $request)

View File

@ -0,0 +1,6 @@
<x-guest-layout>
<div class="mb-4 text-sm text-gray-600">
{{ __('Test E-Mail') }}
</div>
<br><br>
</x-guest-layout>

View File

@ -380,6 +380,20 @@ document.getElementById("MAINTENANCE_MODE-form").addEventListener("change", func
</div> </div>
<button type="submit" class="mt-3 ml-3 btn btn-info">Apply changes</button> <button type="submit" class="mt-3 ml-3 btn btn-info">Apply changes</button>
</form> </form>
<div class="form-group col-lg-8">
<br><br><h5>Test E-Mail setup:</h5>
@if (session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@elseif (session('fail'))
<div class="alert alert-danger">
{{ session('fail') }}
</div>
@endif
</div>
<a href="{{route('SendTestMail')}}"><button class="mt-3 ml-3 btn btn-outline-secondary">Send Test E-Mail</button></a>
{{-- end SMTP settings --}} {{-- end SMTP settings --}}

View File

@ -173,6 +173,7 @@ Route::group([
Route::get('/update/theme', [AdminController::class, 'updateThemes'])->name('updateThemes'); Route::get('/update/theme', [AdminController::class, 'updateThemes'])->name('updateThemes');
Route::get('/panel/config', [AdminController::class, 'showConfig'])->name('showConfig'); Route::get('/panel/config', [AdminController::class, 'showConfig'])->name('showConfig');
Route::post('/panel/config', [AdminController::class, 'editConfig'])->name('editConfig'); Route::post('/panel/config', [AdminController::class, 'editConfig'])->name('editConfig');
Route::get('/send-test-email', [AdminController::class, 'SendTestMail'])->name('SendTestMail');
Route::get('/theme-updater', function () {return view('studio/theme-updater', []);}); Route::get('/theme-updater', function () {return view('studio/theme-updater', []);});
Route::get('/update', function () {return view('update', []);}); Route::get('/update', function () {return view('update', []);});
Route::get('/backup', function () {return view('backup', []);}); Route::get('/backup', function () {return view('backup', []);});