Reputation: 1122
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
Reputation: 11829
There is no exception list.
PHPMailer just a wrapper https://github.com/PHPMailer/PHPMailer/blob/48392076504a2ee4b091d46fec2c3089b71f804a/src/PHPMailer.php#L1632 and error handling depends on a provider
May be useful:
/**
* Constructor.
*
* @param bool $exceptions Should we throw external exceptions?
*/
https://github.com/PHPMailer/PHPMailer/blob/master/src/PHPMailer.php#L826
Example
https://github.com/PHPMailer/PHPMailer/blob/master/examples/exceptions.phps
Also you can enable debug for dev purposes
https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps#L26
Upvotes: 1