Closed CyrilMazur closed 7 years ago
Can you please use https://github.com/laravel/internals for such suggestions?
We keep this repo for bug reporting only.
Is this implemented yet? Would be amazing!
Looks like it's here: https://github.com/laravel/framework/tree/5.5/src/Illuminate/Mail/Events
I upgraded from 5.2 and It's not included.. That's odd.
Description:
There is a
Illuminate\Mail\Events\MessageSending
event that's triggered before the mailer attempts to send an email. Why not also triggering aIlluminate\Mail\Events\MessageSent
event after the email is sent?I think the use case in the example from the official doc is a bit clumsy (https://laravel.com/docs/5.4/mail#events), because the listener for logging the message is executed whether the email is actually sent or not. There could be an error while actually sending the email (ex: network issue, temporary API error from Mandrill / SparkPost etc...) and
MessageSending
would still be triggered. However, it would be guaranteed thatMessageSent
is actually triggered only if the email was successfully sent.On top of that, we could access the message id (SES) / transmission id (SparkPost) that's set into the swift message's headers AFTER the email is sent, allowing us to do nice things like this: