Title: Fatal error not handled
Last modified: March 10, 2020

---

# Fatal error not handled

 *  Resolved [y0uri](https://wordpress.org/support/users/y0uri/)
 * (@y0uri)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/fatal-error-not-handled/)
 * I was testing with plugins and I have WP Mail Logging by MailPoet installed and
   was experimenting with Disable Emails.
 * After enabling Disable Emails, when I select a mail in WP Mail Logging’s mail
   log (checkbox) and choose the bulk action “resend”, your plugin throws an unhandled
   fatal error. Yes, I realize trying to send mail when it’s disabled is stupid,
   but bear with me please.
 * So the mail logging plugin tries to resend the mail, with an $attachments variable
   that is “” (a 0-byte string), which is then exploded on “\n” (just like WP core
   does) resulting in an array with 1 item (so not an empty array, even though the
   1 item is a 0-byte string). Your plugin has set up $phpmailer as PHPMailerMock,
   and when it reaches the part for handling attachments, it calls `$this->phpmailer-
   >AddAttachment($attachment);` which then expectedly throws a `phpmailerException`(
   because an empty string is not an existing file). This is good.
 * However, while you do have a try/catch for `phpmailerException` in your plugin,
   it doesn’t work, because “phpmailerException” is an undefined class. You need
   to add `use \phpmailerException;` to the top of your mock file be able to catch
   phpmailerException exceptions.
 * See? I did something stupid, but found a bug that’s not stupid. 😉
    -  This topic was modified 6 years, 1 month ago by [y0uri](https://wordpress.org/support/users/y0uri/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [webaware](https://wordpress.org/support/users/webaware/)
 * (@webaware)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/fatal-error-not-handled/#post-12530010)
 * G’day y0uri,
 * Excellent detective work! And if I may say, you did nothing stupid, but the bugger
   that didn’t declare the exception class (me) definitely did. Or didn’t do something
   smart, or something!
 * Bug logged, and will be fixed soon. Thanks again!
 * cheers,
    Ross
 *  Thread Starter [y0uri](https://wordpress.org/support/users/y0uri/)
 * (@y0uri)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/fatal-error-not-handled/#post-12533027)
 * Great, Ross, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Fatal error not handled’ is closed to new replies.

 * ![](https://ps.w.org/disable-emails/assets/icon-256x256.png?rev=2590619)
 * [Disable Emails](https://wordpress.org/plugins/disable-emails/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/disable-emails/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/disable-emails/)
 * [Active Topics](https://wordpress.org/support/plugin/disable-emails/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/disable-emails/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/disable-emails/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [y0uri](https://wordpress.org/support/users/y0uri/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/fatal-error-not-handled/#post-12533027)
 * Status: resolved