Support » Plugin: Disable Emails » Fatal error not handled

  • Resolved y0uri


    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 10 months, 1 week ago by y0uri.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author webaware


    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!


    Great, Ross, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal error not handled’ is closed to new replies.