Enabled email test command

This commit is contained in:
Deon George 2022-12-04 14:27:47 +11:00
parent 21236b6871
commit 369f8e48fe
3 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use App\Mail\TestEmail as MailTest;
use App\Models\User;
class SendTestEmail extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'email:test {id}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send a test email';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$uo = User::find($this->argument('id'));
Mail::to($uo->email)
->send(new MailTest($uo));
}
}

48
app/Mail/TestEmail.php Normal file
View File

@ -0,0 +1,48 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use App\Classes\Protocol;
use App\Models\{Setup,User};
class TestEmail extends Mailable
{
use Queueable, SerializesModels;
/* User to send mail to */
public User $user;
/* Our setup object */
public Setup $setup;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(User $o)
{
$this->user = $o;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$this->setup = Setup::findOrFail(config('app.id'));
return $this
->markdown('mail.system.test_email')
->subject('Just a test...')
->with([
'url'=>'https://localhost',
]);
}
}

View File

@ -0,0 +1,31 @@
@component('mail::message',['heading'=>'System Test Email!'])
Hi {{ isset($user) ? $user->name.',' : '' }}
This is just a test email to validate that you can receive emails from us.
@component('mail::panel')
NO ACTION REQUIRED!
@endcomponent
@component('mail::subcopy')
System Test Messsage
@endcomponent
@if($user->systems)
@component('mail::table')
| System Name | Address | FTNs |
| ------------- |:-------------:| --------:|
@foreach ($user->systems as $so)
| {{ $so->name }} | {{ $so->mailer_address }} | {{ $so->addresses->pluck('ftn3d')->join(', ') }} |
@endforeach
@endcomponent
@endif
@component('mail::button', ['url' => $url, 'color' => 'success'])
{{ config('mail.from.name') }}
@endcomponent
Thanks,
{{ $setup->system->sysop }}
@endcomponent