Mail Listener
We can listen to the mail send event.
How to pass custom parameters to a Mail Listener?
The handle method of the listener can get the custom parameters used in the Notification.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** * Handle the event. * * @param object $event * @return void */ public function handle($event) { $userId = false; if (!empty($event->data['userId'])) { $userId = $event->data['userId']; } } |
Delivery Notification Uncertainty
One thing that is set as an unresolved challenge is to know for certain whether an email is delivered or not using Laravel’s Mail.
So there’s this:
Mail::failures()
but this does not tell us for certain whether an email is delivered or not. For e.g. for a valid domain and an invalid username (or even for an invalid domain name), the email shows as delivered (since the failures method returns empty. Failures is expected to return an array of undelivered email addresses) where it wasn’t. After reading a few guides I even tried try-catch with catching the default exception or swift exception but no luck so far. This is still an unresolved challenge that does require to be solved.