User tests: Successful: Unsuccessful:
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.
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.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Libraries |
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-03-22 22:35:30 |
Closed_By | ⇒ | wilsonge |
Milestone |
Added: |
$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).
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?
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.
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.