Rick Hellewell
Rick Hellewell

Reputation: 1122

Possible PHPMailer Error messages for better error handling

I understand that PHPMailer will give you an error if the mail fails:

    if (!$mail->send()) {
      echo "Mailer Error: " . $mail->ErrorInfo) . PHP_EOL;
    }

And I could use a 'try/catch' processing for the $mail->send.

But is there a list of PHPMailer error messages that I can use for better error handling? I've looked in the PHPMailer docs, and have searched here and other places, but have not found a comprehensive list of possible errors. (There is this question phpmailer error codes for outcome processing from 2015, but the answer didn't help me.)

Or are the error messages dependent on the mail server?

I'd like to trap certain errors, like an invalid email, or a 'mail send error', etc. And maybe ignore some errors (although I'm not sure which ones to avoid, since I can't find a list of possible errors).

I suppose I could dig through the source code to find them, but wondering if somebody has already complied that information.

So, looking for PHPMailer ErrorInfo values - or code that you use to catch errors.

Upvotes: 1

Views: 836

Answers (1)

Related Questions