diff --git a/app/Http/Controllers/TestEmailController.php b/app/Http/Controllers/TestEmailController.php new file mode 100644 index 0000000..0c4deee --- /dev/null +++ b/app/Http/Controllers/TestEmailController.php @@ -0,0 +1,46 @@ +validate($request, [ + 'recipient' => 'required|email', + ]); + + $recipient = $request->input('recipient'); + $config = [ + 'driver' => config('mail.driver'), + 'host' => config('mail.host'), + 'port' => config('mail.port'), + 'username' => config('mail.username'), + 'encryption' => config('mail.encryption'), + ]; + + try { + Mail::send('emails.test', ['config' => $config, 'recipient' => $recipient], function ($message) use ($recipient) { + $message->from('no-reply@crewsportswear.com', 'CREW Sportswear'); + $message->to($recipient)->subject('CREW Sportswear — Test Email'); + }); + + $status = 'success'; + $message = 'Test email sent successfully to ' . $recipient . '.'; + } catch (\Exception $e) { + $status = 'danger'; + $message = 'Failed to send email: ' . $e->getMessage(); + } + + return redirect()->back()->with('status', $status)->with('message', $message); + } +} diff --git a/app/Http/routes.php b/app/Http/routes.php index f375712..8e974ed 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -41,6 +41,10 @@ Route::get('cart', ['as' => 'cart', 'uses' => 'teamstore\TeamStoreController@car Route::get('/checkout', 'teamstore\TeamStoreController@checkout'); Route::get('/mail', 'teamstore\TeamStoreController@mail'); +// Test email page +Route::get('/test-email', 'TestEmailController@show'); +Route::post('/test-email/send', 'TestEmailController@send'); + Route::get('/designer/{templateid}', 'designer\DesignerController@index'); Route::get('/designer/preview/{designCode}', 'designer\DesignerController@getDesign'); diff --git a/resources/views/emails/test.blade.php b/resources/views/emails/test.blade.php new file mode 100644 index 0000000..0d09046 --- /dev/null +++ b/resources/views/emails/test.blade.php @@ -0,0 +1,23 @@ + + + + + Test Email — CREW Sportswear + + +

CREW Sportswear — Test Email

+

This is a test email to verify that the mail configuration is working correctly.

+

Sent to: {{ $recipient }}

+
+

+ Mail Config Used:
+ Driver: {{ $config['driver'] }}
+ Host: {{ $config['host'] }}
+ Port: {{ $config['port'] }}
+ Username: {{ $config['username'] }}
+ Encryption: {{ $config['encryption'] }} +

+
+

This is an automated test message from CREW Sportswear.

+ + diff --git a/resources/views/test-email.blade.php b/resources/views/test-email.blade.php new file mode 100644 index 0000000..7feefec --- /dev/null +++ b/resources/views/test-email.blade.php @@ -0,0 +1,55 @@ +@extends('layout.main') + +@section('content') +
+
+
+
+

Send Test Email

+
+
+ + @if (session('message')) + + @endif + + +
+ Current Mail Config
+ Driver: {{ config('mail.driver') ?: '(not set)' }}
+ Host: {{ config('mail.host') ?: '(not set)' }}
+ Port: {{ config('mail.port') ?: '(not set)' }}
+ Username: {{ config('mail.username') ?: '(not set)' }}
+ Encryption: {{ config('mail.encryption') ?: '(not set)' }} +
+ +
+ {!! csrf_field() !!} +
+ + + @if ($errors->has('recipient')) + {{ $errors->first('recipient') }} + @endif +
+ +
+ +
+
+
+
+@endsection