? Pending

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
12 Apr 2016

Summary of Changes

Because PHPMailer::setFrom() throws Exceptions (or returns boolean false depending on configuration), assuming that errors are correctly checked, it is possible for the creation of a JMail object via JFactory to fail catastrophically. This PR changes JFactory::createMailer() to validate the e-mail address in the global configuration before attempting to set it in the PHPMailer API and will handle error states if setFrom() fails, which allows a JMail object to be created but will NOT contain the sender data if so.

Testing Instructions

Validate JMail objects are created with invalid sender data in your global configuration.

avatar mbabker mbabker - open - 12 Apr 2016
avatar mbabker mbabker - change - 12 Apr 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 Apr 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 12 Apr 2016
Category Libraries
avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Apr 2016

i tried to test this, but didn't notice any difference.

I was unable to do a ...

creation of a JMail object via JFactory to fail catastrophically

Can you give more instructions on how to get the failure?

avatar mbabker
mbabker - comment - 13 Apr 2016

Try making sure the sender data in your global config isn't valid (especially the email address). I truthfully don't know how to reproduce it but someone commented on the function being able to fail and code wise I can trace down why it would but I don't have a configuration that causes the failure.

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Apr 2016

but the thing is i can't make a INvalid e-mail in global config :)

but i tried also in the configuration.php and can't reproduce the failure.
With or without the PR i get always a 500 error "Invalid address: ".

avatar mbabker
mbabker - comment - 13 Apr 2016

What's the stack trace? Is the 500 coming from this JFactory method or something else?

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Apr 2016

Using global config "Send Test Mail" with empty from e-mail.

Without patch

JFactory::createMailer() /libraries/joomla/factory.php:349
PHPMailer->setFrom() /libraries/joomla/factory.php:675

With Patch

JMail->sendMail() /administrator/components/com_config/model/application.php:493
JMail->addRecipient() /libraries/joomla/mail/mail.php:566
JMail->add() /libraries/joomla/mail/mail.php:309
PHPMailer->addAddress() /libraries/joomla/mail/mail.php:291
PHPMailer->addOrEnqueueAnAddress() /libraries/vendor/phpmailer/phpmailer/class.phpmailer.php:79
avatar mbabker
mbabker - comment - 13 Apr 2016

Well, good news is this patch is working then. Bad news is you need #9881 to catch the other exception that's being thrown.

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Apr 2016

ok so this i mark as tested success right?

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Apr 2016

BTW, after applying ALSO #9881 i finally get a "Test mail could not be sent." :)

avatar mbabker
mbabker - comment - 13 Apr 2016

Yes. The point of this patch is to cause JFactory::getMailer() to not raise an error when creating a JMail object, and that's no longer happening.

avatar andrepereiradasilva andrepereiradasilva - test_item - 13 Apr 2016 - Tested successfully
avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Apr 2016

I have tested this item :white_check_mark: successfully on 4be976c

as comments above


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9880.

avatar andrepereiradasilva
andrepereiradasilva - comment - 13 Apr 2016

BTW if, in the same test, i ONLY use #9881 i get also the "Test mail could not be sent." message

avatar wilsonge wilsonge - change - 7 May 2016
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-05-07 14:15:06
Closed_By wilsonge
avatar wilsonge wilsonge - close - 7 May 2016
avatar wilsonge wilsonge - merge - 7 May 2016

Add a Comment

Login with GitHub to post a comment