How do you check the actual error in SwiftMailer v4 when send () is not working

Is there a way to check the error when sending mail using SwiftMailer version 4? I do not mean getting a list of letters of recipients that were rejected, and I'm not saying that I simply know whether send () works or not.

I am talking about knowing the actual error that occurred during the sending process, for example, the inability to connect to the STMP host, incorrect login, etc.

+3
source share
1 answer

Just check the return code of the SwiftMailer send () or batchSend () commands for a non-zero result. If you get a non-zero result (i.e. TRUE), it succeeds in connecting and authenticated to your SMTP service.

:

//Send the message
$numSent = $mailer->send($message);

printf("Sent %d messages\n", $numSent);

// Note that often that only the boolean equivalent of the
//  return value is of concern (zero indicates FALSE) 

if ($mailer->send($message))
{
  echo "Sent\n";
}
else
{
  echo "Failed\n";
}
-1

All Articles