I'm using laravel 5.7, so when sending an email using Mail interface two events fired Mail\Events\MessageSending and Mail\Events\MessageSent, so my goal is to catch MessageSending event and get the mailabe class used to send the email (example mail\Ordershipped) and stop it.
<?php
namespace App\Listeners;
use Illuminate\Mail\Events\MessageSending;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class LogSendingMessage
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param MessageSending $event
* @return void
*/
public function handle(MessageSending $event)
{
//here i want to check what mailable class used and stop it.
if ($mailable == 'Ordershipped')
return false;
// if another mailable class (example: userVerification)
else
return true;
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BvyUd1
via IFTTT
Aucun commentaire:
Enregistrer un commentaire