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 »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • Custom mail headers
Pages: [1]

Author Topic: Custom mail headers  (Read 1913 times)

mbriney

  • I’m new here
  • *
  • Posts: 21
  • Karma: 2
  • Technical Product Manager / VP at Edelman
    • Edelman Public Relations
Custom mail headers
May 27, 2010, 06:44:44 am
We would like to add a custom mail header to all outbound e-mails (X-xsMailingId) so that we can track jobs with our 3rd party MTA.  I know this will be a core modification most likely.  But does anyone know in which file we can make this change?
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

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: Custom mail headers
May 27, 2010, 07:29:57 am

this can be done via a hook?

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmalterMailParams

if not, we should extend civicrm to make this possible via a hook

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

mbriney

  • I’m new here
  • *
  • Posts: 21
  • Karma: 2
  • Technical Product Manager / VP at Edelman
    • Edelman Public Relations
Re: Custom mail headers
May 27, 2010, 08:05:01 am
This seems to be tied mostly to a form action though.  We're looking to do the headers on CiviMail outbound campaigns.  We probably wouldn't be able to call the hook without modifying the core anyways.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

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: Custom mail headers
May 27, 2010, 01:29:22 pm

in 3.2, two places u'll need to set the headers:

CRM/Mailing/BAO/Mailing.php, (search for $message->headers( $headers );)

CRM/Utils/Mail.php (search for $msg->headers($headers);)

the hook is not form dependent. however i did take a quick glance at it and seems like we cannot inject headers via the hook as it stands now

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

mbriney

  • I’m new here
  • *
  • Posts: 21
  • Karma: 2
  • Technical Product Manager / VP at Edelman
    • Edelman Public Relations
Re: Custom mail headers
May 28, 2010, 07:46:07 am
Thanks Lobo,

It looks like I only had to adjust: CRM/Mailing/BAO/Mailing.php

Right after $headers['Precedence'] = 'bulk';

I added the line:

$headers['X-xsMailingId'] = 'ClientName-'.$job_id;

The headers merged properly in the e-mails and we're geting the tracking we need.

One question I do have is instead of using $job_id is there any way we can access and merge $mailing_id instead?

Thanks,
-matt
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

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: Custom mail headers
May 28, 2010, 08:45:51 am

a mailing can potentially have multiple jobs (in the schema) and hence job id is a more accurate record to identify a sent email. if you do want the mailing ID, i'd recommend you add the job_id.mailing_id (though u can get the mail id from the job id). You might also want to add the event_queue_id so you can track which exact email it was

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

mbriney

  • I’m new here
  • *
  • Posts: 21
  • Karma: 2
  • Technical Product Manager / VP at Edelman
    • Edelman Public Relations
Re: Custom mail headers
May 28, 2010, 09:32:26 am
That is a good thought to include all of the IDs.

How can we do a lookup of the #mailing_id?  Is there an API call we can make to retrieve that?  I didn't see anything in the public APIs that would reference that table.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • Custom mail headers

This forum was archived on 2017-11-26.