? Failure

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
22 Mar 2016

Summary of Changes

When PHPMailer raises an error, regardless of your error handling preference, it calls the internal edebug function to act as a processor for errors. A default handler is set up in JMail's constructor to log errors from the library since Joomla elects to use boolean values for errors versus Exceptions.

Next, the constructor value for PHPMailer which allows Exceptions to be enabled is now supported in JMail. It defaults to false, same as the current behavior, but allows someone using the API to turn on Exceptions instead of boolean values. This parameter addition propogates into JMail::getInstance() as well.

Testing Instructions

Trigger an error in PHPMailer. A log statement should be added. If Exceptions are turned on, a phpmailerException should be thrown instead of returning a boolean false.

avatar mbabker mbabker - open - 22 Mar 2016
avatar mbabker mbabker - change - 22 Mar 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 22 Mar 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 22 Mar 2016
Category Libraries
avatar wilsonge wilsonge - change - 22 Mar 2016
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-03-22 22:35:30
Closed_By wilsonge
avatar wilsonge wilsonge - close - 22 Mar 2016
avatar wilsonge wilsonge - merge - 22 Mar 2016
avatar wilsonge wilsonge - reference | 24cf7ca - 22 Mar 16
avatar wilsonge wilsonge - merge - 22 Mar 2016
avatar wilsonge wilsonge - close - 22 Mar 2016
avatar wilsonge wilsonge - change - 22 Mar 2016
Milestone Added:
avatar mbabker mbabker - head_ref_deleted - 30 Mar 2016
avatar OctavianC
OctavianC - comment - 5 Apr 2016

Can we set $exceptions = false by default since this was the previous behavior? I'm guessing a lot of code depended on the result of $mail->send() and with exceptions by default, this will no longer work.

avatar mbabker
mbabker - comment - 5 Apr 2016

$mail->send() is still returning false since it's catching thrown phpmailerException objects (the only ones PHPMailer throws), and this has to happen to deal with other quirks of PHPMailer. If you really need to force PHPMailer to never throw Exceptions you can instantiate a new JMail object with the right config (you can't use JFactory::getMailer() since it caches a singleton instance).

avatar OctavianC
OctavianC - comment - 5 Apr 2016

I haven't really debugged it to that extent, but you're probably right; however I'm underlining the fact that exceptions weren't enabled by default, why are they now? Wouldn't this break b/c in some cases?

avatar mbabker
mbabker - comment - 5 Apr 2016

Depends on what you consider a B/C break to be. Adding an address will now throw a phpmailerException instead of returning a boolean false if something goes wrong, IMO this is better for the API (the Exception has a real error message attached to it while a boolean false leaves you guessing). The return values on the API aren't changing, but there are now new paths that may throw an Exception before reaching those return points.

Add a Comment

Login with GitHub to post a comment