Add TestEmailController and views for sending test emails
All checks were successful
Deploy Production (crewsportswear.com) / deploy (push) Successful in 2m51s
All checks were successful
Deploy Production (crewsportswear.com) / deploy (push) Successful in 2m51s
This commit is contained in:
46
app/Http/Controllers/TestEmailController.php
Normal file
46
app/Http/Controllers/TestEmailController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class TestEmailController extends Controller
|
||||
{
|
||||
|
||||
public function show()
|
||||
{
|
||||
return view('test-email');
|
||||
}
|
||||
|
||||
public function send(Request $request)
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
23
resources/views/emails/test.blade.php
Normal file
23
resources/views/emails/test.blade.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test Email — CREW Sportswear</title>
|
||||
</head>
|
||||
<body style="font-family: Arial, sans-serif; color: #333; padding: 20px;">
|
||||
<h2 style="color: #d9534f;">CREW Sportswear — Test Email</h2>
|
||||
<p>This is a test email to verify that the mail configuration is working correctly.</p>
|
||||
<p>Sent to: <strong>{{ $recipient }}</strong></p>
|
||||
<hr>
|
||||
<p style="font-size: 12px; color: #777;">
|
||||
<strong>Mail Config Used:</strong><br>
|
||||
Driver: {{ $config['driver'] }}<br>
|
||||
Host: {{ $config['host'] }}<br>
|
||||
Port: {{ $config['port'] }}<br>
|
||||
Username: {{ $config['username'] }}<br>
|
||||
Encryption: {{ $config['encryption'] }}
|
||||
</p>
|
||||
<hr>
|
||||
<p style="font-size: 12px; color: #aaa;">This is an automated test message from CREW Sportswear.</p>
|
||||
</body>
|
||||
</html>
|
||||
55
resources/views/test-email.blade.php
Normal file
55
resources/views/test-email.blade.php
Normal file
@@ -0,0 +1,55 @@
|
||||
@extends('layout.main')
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-md-offset-3" style="margin-top: 40px; margin-bottom: 40px;">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><strong>Send Test Email</strong></h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
@if (session('message'))
|
||||
<div class="alert alert-{{ session('status') }} alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
{{ session('message') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Mail Config Info -->
|
||||
<div class="well well-sm" style="font-size: 12px;">
|
||||
<strong>Current Mail Config</strong><br>
|
||||
Driver: <code>{{ config('mail.driver') ?: '(not set)' }}</code><br>
|
||||
Host: <code>{{ config('mail.host') ?: '(not set)' }}</code><br>
|
||||
Port: <code>{{ config('mail.port') ?: '(not set)' }}</code><br>
|
||||
Username: <code>{{ config('mail.username') ?: '(not set)' }}</code><br>
|
||||
Encryption: <code>{{ config('mail.encryption') ?: '(not set)' }}</code>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ url('test-email/send') }}">
|
||||
{!! csrf_field() !!}
|
||||
<div class="form-group{{ $errors->has('recipient') ? ' has-error' : '' }}">
|
||||
<label for="recipient">Recipient Email</label>
|
||||
<input type="email"
|
||||
name="recipient"
|
||||
id="recipient"
|
||||
class="form-control"
|
||||
placeholder="you@example.com"
|
||||
value="{{ old('recipient') }}"
|
||||
required>
|
||||
@if ($errors->has('recipient'))
|
||||
<span class="help-block">{{ $errors->first('recipient') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">
|
||||
<i class="fa fa-envelope"></i> Send Test Email
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user