mailersend-laravel-driver
mailersend-laravel-driver copied to clipboard
Add support for failover
Laravel provides failover configuration for the mail drivers. That means, in case the mail driver doesn't work, it would retry with the next registered driver to send emails. Doc: https://laravel.com/docs/10.x/mail#failover-configuration
Currently, it doesn't work with mailersend.
The reason it doesn't work is because Symfony's Mail Transport catches exceptions through TransportExceptionInterface.
However, when something goes wrong, MailerSend throws MailerSendException.
Ref: https://github.com/symfony/mailer/blob/7.0/Transport/RoundRobinTransport.php#L56-L60
And because of that, it doesn't find the exception and can not retry with another fallback driver.
Now to make this work, we need to throw TransportException instead of MailerSendException.
We should catch MailerSendHttpException and "convert" it to TransportException. In other cases, return MailerSendException as intended.
@kavanpancholi I think we can close this one right?
Yes for sure. Closing now.