Configure Exim to log a given header of all emails sent

eximsmtp

I maintain a custom built web application. Any time this application sends an email, it adds a custom header X-UUID to the mail, to assist me in tracking abuse and email delivery. This UUID is written to my application's log file so I can correlate any given email with what was happening in my application at that time.

Is it possible to configure Exim on the cPanel server which delivers these emails to log this X-UUID header in the exim_mainlog file? For example, could these existing log entries:

2011-12-05 11:38:18 1RXbYY-00074m-0T <= www-data@trees.sitepalette.com H=oak01.sitepalette.com (trees.sitepalete.com) [172.16.1.50] P=esmtp S=7779 id=20111205163823.5366C1172@trees.sitepalete.com
2011-12-05 11:38:18 1RXbYY-00074m-0T => redacted@redactedcom R=lookuphost T=remote_smtp H=redacted.redacted.redacted.net [111.222.333.444]
2011-12-05 11:38:18 1RXbYY-00074m-0T Completed

be changed to somehow include this header? Something like:

2011-12-05 11:38:18 1RXbYY-00074m-0T <= www-data@trees.sitepalette.com H=oak01.sitepalette.com (trees.sitepalete.com) [172.16.1.50] P=esmtp S=7779 id=20111205163823.5366C1172@trees.sitepalete.com
2011-12-05 11:38:18 1RXbYY-00074m-0T X-UUID: 2b1d7e3f-0ca0-4790-a21d-a5922cd34002
2011-12-05 11:38:18 1RXbYY-00074m-0T => redacted@redactedcom R=lookuphost T=remote_smtp H=redacted.redacted.redacted.net [111.222.333.444]
2011-12-05 11:38:18 1RXbYY-00074m-0T Completed

Best Answer

UPDATE: My server updated to cPanel / WHM 11.32.0 (build 1) this morning and I received an email stating

cPanel was unable to automatically merge your Exim configuration with the new settings that shipped with the build you have installed (11.32.0 (build 1)) because you have a custom or broken configuration which cannot be automatically configured

To fix this, I had to change my custom ACL to:

warn logwrite = X-UUID=$h_X-UUID:; Subject=$h_Subject:

I placed this new ACL in the custom_begin_check_message_pre section at the top of acl_smtp_data: under the cPanel "Advanced Exim Configuration Editor" (accessed by going to Main >> Service Configuration >> Exim Configuration Editor and then clicking the Advanced Editor)

enter image description here

Below are the steps I was following for my previous cPanel / WebHostManager version:


I was able to figure this out with the help of a post on cPanel's forums.

I used the cPanel "Advanced Exim Configuration Editor" accesed by going to Main >> Service Configuration >> Exim Configuration Editor and then clicking the Advanced Editor button at the bottom of the page. I placed the following configuration directives inside the begin acl section right before the begin authenticators section:

logwrite = X-UUID=$h_X-UUID:; Subject=$h_Subject:

Screencapture of the above

Now, my log files look like:

2012-01-06 15:13:18 H=hatchet.sitepalette.com (trees.sitepalete.com) [172.16.1.60] Warning: Sender rate 3.6 / 1h

2012-01-06 15:13:18 1RjGAA-0007ec-B1 1RjGAA-0007ec-B1: UUID=4e4b6985-c1e0-4386-92e0-f3c17a2fc777; Subject=Email Form "signup" Submission
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2012-01-06 15:13:18 1RjGAA-0007ec-B1 <= www-data@trees.sitepalette.com H=hatchet.sitepalette.com (trees.sitepalete.com) [172.16.1.60] P=esmtp S=3182 id=20120106201319.76CE7119C@trees.sitepalete.com
2012-01-06 15:13:18 1RjGAA-0007ec-B1 => josh <josh@digitalfruition.com> R=virtual_user T=virtual_userdelivery
2012-01-06 15:13:18 1RjGAA-0007ec-B1 Completed

(Edited to indicate the header logging)

Related Topic