CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Problem with multiple "To" addresses in report
Pages: [1]

Author Topic: Problem with multiple "To" addresses in report  (Read 640 times)

labrown

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
Problem with multiple "To" addresses in report
June 13, 2012, 11:29:57 am
Greetings,

The help text for the 'Email Delivery Settings' section in the 'Report Settings' includes the text, 'Multiple email addresses should be separated by commas.'  When I enter multiple bare addresses in the 'To' field separated by commas the resulting To: header in the outbound email is very poorly formed.

For example, The entry:

Code: [Select]
xxxx.yyy@foo.bar.com,brown@stat.duke.edu
results in a To: header that looks like:

Code: [Select]
To: <"xxxx.yyy@foo.bar.com, brown"@stat.duke.edu>
Somehow, CiviCRM manages to deliver the messages to the correct addresses in the SMTP transaction, but that To: header is very very broken.

I traced through the code and it looks like the mailReport function in CRM/Report/Utils/Report.php calls CRM_Utils_Mail::send to send the report email, but that the 'send' function is expecting a _single_ email address in the 'toEmail' variable.  The relevant bits of code are:

from Report.php 'mailReport' function:

Code: [Select]
        $params                = array( );
        $params['groupName'  ] = 'Report Email Sender';
        $params['from'       ] = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
        $params['toName'     ] = ""; //$domainEmailName;
        $params['toEmail'    ] = CRM_Utils_Array::value( 'email_to', $instanceInfo );
        $params['cc'         ] = CRM_Utils_Array::value( 'email_cc', $instanceInfo );
        $params['subject'    ] = CRM_Utils_Array::value( 'email_subject', $instanceInfo );
        if ( !CRM_Utils_Array::value( 'attachments', $instanceInfo ) ) {
            $instanceInfo['attachments'] = array();
        }
        $params['attachments'] = array_merge(CRM_Utils_Array::value( 'attachments', $instanceInfo ), $attachments);
        $params['text'       ] = '';
        $params['html'       ] = $fileContent;

        require_once "CRM/Utils/Mail.php";
        return CRM_Utils_Mail::send( $params );

toName is blank and toEmail is set to the value of the 'To' field in the Report settings.

Then, in the CRM_Utils_Mail::send function:

Code: [Select]
        $headers['To']                        = self::formatRFC822Email( CRM_Utils_Array::value( 'toName', $params ),
                                                                         CRM_Utils_Array::value( 'toEmail', $params ),
                                                                         false );

This munges the toName and toEmail variables together into a supposedly  RFC822 legal email address, which in this case fails.

Either the help text in the Report Settings section needs to be changed or the mailReport and/or send functions need to be modified to support multiple 'To' addresses.

Thanks,
  --[Lance]

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Problem with multiple "To" addresses in report
June 13, 2012, 08:20:57 pm

For 4.2, i suspect the easiest solution might be to fix the help text.

Can you please create a patch that fixes the help text, file an issue and attach the patch

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

labrown

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
Re: Problem with multiple "To" addresses in report
June 14, 2012, 01:54:03 pm
Issue created.  http://issues.civicrm.org/jira/browse/CRM-10392

--[Lance]

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Problem with multiple "To" addresses in report

This forum was archived on 2017-11-26.