User tests: Successful: Unsuccessful:
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.
Validate JMail
objects are created with invalid sender data in your global configuration.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Libraries |
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.
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: ".
What's the stack trace? Is the 500 coming from this JFactory method or something else?
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
ok so this i mark as tested success right?
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.
I have tested this item successfully on 4be976c
as comments above
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-05-07 14:15:06 |
Closed_By | ⇒ | wilsonge |
i tried to test this, but didn't notice any difference.
I was unable to do a ...
Can you give more instructions on how to get the failure?