osb/app/Listeners/LogSentMessage.php
2022-06-25 00:18:57 +10:00

31 lines
732 B
PHP

<?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()]);
}
}