How the laravel Mail::failures() function works?

I’ve been trying to get the list of recipients who did not get email using laravel Mail::send() function. I am trying following code. for loop is used as because each user to be received customized message.

// First recipient is actual, the second is dummy.
$mail_to_users = ["",""];
$failures = [];

foreach($mail_to_users as $mail_to_user) {
   Mail::send('email', [], function($msg) use ($mail_to_user){
     $msg->subject("Document Shared");

   if( count( Mail::failures() ) > 0 ) {
      $failures[] = Mail::failures()[0];


I’ve been trying all the possible option. I changed the correct mail config in config/mail.php to the wrong one. But if I do this then laravel shows error page, but $failure variable always return empty.

Source: laravel

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.