?
avatar spignataro
spignataro
20 May 2016

Steps to reproduce the issue

$mailer = JFactory::getMailer();
$config = JFactory::getConfig();

$recipient = "myemail@home.com";
$cc = array();
$bcc = array();

$sender = array(
$config->get( 'mailfrom' ),
$config->get( 'fromname' )
);

$mailer->setSender($sender);
$mailer->addRecipient( $recipient );
$mailer->addCC( $cc );
$mailer->addBCC( $bcc );

The above code is not exact to what we currently have had for the past few years but more or less what the end result is. The issue is that $cc and $bcc variables get filled in from an input variable but in some cases it ends up returning an array with a key of 0 with a value of NULL. This has never been a problem until the recent update of Joomla! 3.5+. What ends up happening now is that phpmailer rejects this and says that this an Invalid Address and breaks the site.

Expected result

The expected result for null values is to have JMailer ignore cc or bcc and send the email out instead of just failing and erroring out to the page.

Actual result

http://screencast.com/t/VQMStt6X17n

avatar spignataro spignataro - open - 20 May 2016
avatar mbabker
mbabker - comment - 20 May 2016

PHPMailer has always rejected this but due to the piss-poor non-existing error handling in JMail said error was never reported until PHPMailer's exceptions started to be thrown with the 3.5.1 release. There are error handling mechanisms in place for the next release, but you should still validate that you actually have a string to pass into those methods (even better to do a quick JMailHelper::isEmailAddress($address) check) before calling them.

avatar spignataro
spignataro - comment - 20 May 2016

Michael - I agree - just an FYI this isn't my code. But this has effected quite a few sites that broke after the update. While I agree that people should be performing their own checks it just sucks that there was no additional checking in JMailer to prevent sites from breaking that have been working for some time.

avatar mbabker
mbabker - comment - 20 May 2016

They haven't been working, that's the main point. PHPMailer before 3.5.1 was returning a boolean false on addCC and addBCC (and other addXXX methods setting email addresses) in those cases but JMail never detected the error condition or reported it so from the implementor's side it all looked like it worked without issue. 3.5.1 made PHPMailer more strict about actually raising errors to the point that it exposed years of crap code in JMail that would in no possible way report an error on any method other than Send. It's better handled with the merge of #9881 but there's still a B/C break involved because the methods can now return booleans instead of only returning $this for chaining.

Whoever implemented JMail screwed up royally by changing the method signatures and returns from the parent PHPMailer class and not checking for any error conditions at all. Plain and simple. That's given the false impression that mail sending always worked when in reality invalid data was never getting added to the message nor was the invalid data being reported up the chain as such.

avatar roland-d roland-d - change - 20 May 2016
Status New Known Issue
Closed_Date 0000-00-00 00:00:00 2016-05-20 15:11:36
Closed_By roland-d
avatar roland-d
roland-d - comment - 20 May 2016

We are aware that JMail isn't implemented as it should but not something we can fix in Joomla 3. This would have to be redone in a new major version.

Thank you for your contribution.


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

avatar roland-d roland-d - close - 20 May 2016
avatar roland-d roland-d - close - 20 May 2016
avatar brianteeman brianteeman - reopen - 20 May 2016
avatar brianteeman brianteeman - change - 20 May 2016
Category Libraries
avatar roland-d roland-d - change - 21 May 2016
Status New Closed
Closed_Date 2016-05-20 15:11:36 2016-05-21 09:29:14
avatar roland-d roland-d - close - 21 May 2016
avatar brianteeman brianteeman - close - 21 May 2016
avatar brianteeman brianteeman - change - 27 May 2016
Labels Added: ?

Add a Comment

Login with GitHub to post a comment