Log sent emails
This commit is contained in:
parent
b0a317d709
commit
f6f502618d
31
app/Listeners/LogSentMessage.php
Normal file
31
app/Listeners/LogSentMessage.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Events\MessageSent;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LogSentMessage
|
||||
{
|
||||
private const LOGKEY = 'LSM';
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param MessageSent $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(MessageSent $event)
|
||||
{
|
||||
Log::debug(
|
||||
sprintf('%s:Email to [%s] with subject [%s] sent [%s]',
|
||||
self::LOGKEY,
|
||||
collect($event->data['message']->getTo())->transform(function($item) { return $item->getAddress(); })->join(','),
|
||||
$event->data['message']->getSubject(),
|
||||
$event->sent->getMessageId(),
|
||||
),
|
||||
['debug'=>$event->sent->getDebug()]);
|
||||
}
|
||||
}
|
@ -13,9 +13,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'App\Events\Event' => [
|
||||
'App\Listeners\EventListener',
|
||||
],
|
||||
'Illuminate\Mail\Events\MessageSent' => [
|
||||
'App\Listeners\LogSentMessage',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -26,7 +26,5 @@ class EventServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user