4

I have recently upgraded my Laravel application from 5.8 to 9.x. In the previous version of Laravel, mail transport was done by SwiftMailer. But now in Laravel 9, it uses SymfonyMailer.

To get the failed recipient list, Mail::failures() was used, which returned an array of email addresses. In Laravel 9, this method is not available.

Is there any way to get the array of failed recipients?

1 Answers1

2

Does this helps, https://symfony.com/doc/current/mailer.html#handling-sending-failures

Symfony Mailer considers that sending was successful when your transport (SMTP server or third-party provider) accepts the mail for further delivery. The message can later be lost or not delivered because of some problem in your provider, but that's out of reach for your Symfony application.

If there's an error when handing over the email to your transport, Symfony throws a TransportExceptionInterface. Catch that exception to recover from the error or to display some message:

use Symfony\Component\Mailer\Exception\TransportExceptionInterface;

$email = new Email();
// ...
try {
    $mailer->send($email);
} catch (TransportExceptionInterface $e) {
    // some error prevented the email sending; display an
    // error message or try to resend the message
}
Vipertecpro
  • 3,056
  • 2
  • 24
  • 43