(Add) New Email Test Command

- running `php artisan test:email` will test your mailer configuration
and attempt to fire a email off to the owners email address. This will
be mainly used for the UNIT3D Installer created by @poppabear8883
This commit is contained in:
HDVinnie
2018-08-05 18:02:01 -04:00
parent 160b0cdf3c
commit a989584070
5 changed files with 119 additions and 2 deletions
+64
View File
@@ -0,0 +1,64 @@
<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
namespace App\Console\Commands;
use Illuminate\Support\Facades\Mail;
use Illuminate\Console\Command;
use App\Mail\TestEmail;
use App\User;
class testMailSettings extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test:email';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send a test email to owner account using the current mail configuration';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$owner = User::where('id', '=', 3)->pluck('email');
$this->info('Sending Test Email To ' . $owner);
sleep(5);
$abort = false;
try {
Mail::to($owner)->send(new TestEmail());
} catch (\Exception $e) {
$abort = true;
}
if ($abort) {
$this->error('Failed!');
$this->alert('Email failed to send. Please review your mail configs in the .env file.');
} else {
$this->alert('Email Was Successfully Sent!');
}
}
}
+2 -1
View File
@@ -34,7 +34,8 @@ class Kernel extends ConsoleKernel
\App\Console\Commands\recycleFailedLogins::class,
\App\Console\Commands\demoSeed::class,
\App\Console\Commands\gitUpdate::class,
\App\Console\Commands\clearCache::class
\App\Console\Commands\clearCache::class,
\App\Console\Commands\testMailSettings::class
];
/**
+44
View File
@@ -0,0 +1,44 @@
<?php
/**
* NOTICE OF LICENSE
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class TestEmail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.test_email');
}
}
+1 -1
View File
@@ -54,7 +54,7 @@ return [
|
*/
'email' => 'none@none.com',
'email' => env('DEFAULT_OWNER_EMAIL', 'unit3d@none.com'),
/*
|--------------------------------------------------------------------------
@@ -0,0 +1,8 @@
@component('mail::message')
# Test Email
Your test email has been successfully delivered! Looks like your mail configs are on point!
Thanks,
{{ config('other.title') }}
@endcomponent