Results 1 to 9 of 9

Thread: change x-header-from and x-header-to while sending email

  1. #1
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default change x-header-from and x-header-to while sending email

    Hello guys,

    I want to change x-header-from and x-header-to with specific values when somebody sends email from zimbra.

    Basically, I want to implement a journaling server for my new zimbra setup. I will keep that journaling server email into BCC of every email sent from zimbra. But I want x-header-from should be set to journal@example.com and x-header-to should be all the TO and BCC list for journaling email.

    Please let me know how can I achieve this kind of functionality.

    Zimbra Version is: Release 7.1.0_GA_3140.UBUNTU10_64 UBUNTU10_64 NETWORK edition.

    Thanks.

  2. #2
    Join Date
    Apr 2011
    Location
    Slovakia
    Posts
    18
    Rep Power
    4

    Default

    Hi stalker,

    I'd suppose you could achieve most of the desired functionality by tweaking the Zimbra's postfix, have a look at:
    Postfix manual - header_checks(5)

    But you have to be careful, because according to what you've written, the real recipient will see the BCC addresses of the message in the x-header-to field.

    And why can't the journaling server use the real "From:" and "To:" fields?
    Michal Belica - IT consultant
    www.beli.sk

  3. #3
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default

    Quote Originally Posted by beli.sk View Post
    Hi stalker,

    I'd suppose you could achieve most of the desired functionality by tweaking the Zimbra's postfix, have a look at:
    Postfix manual - header_checks(5)

    But you have to be careful, because according to what you've written, the real recipient will see the BCC addresses of the message in the x-header-to field.

    And why can't the journaling server use the real "From:" and "To:" fields?
    Thanks for the link. Yes, journaling server can use from and to field. But I think we are going to alter from field. So, it will be same for every email.

  4. #4
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default

    Now I am able to add X-Header-From in to all emails. But cannot add second one.

    I've wrote following file code into header_checks regexp map.

    /^To: (.*)/ PREPEND X-Header-From: journaling@xyz.com
    /^(Cc:|Bcc(.*)/ PREPEND X-Header-To: Should be cc and bcc

    But it is not working. Can you tell me what is wrong?

  5. #5
    Join Date
    Apr 2011
    Location
    Slovakia
    Posts
    18
    Rep Power
    4

    Default

    I'd rather prepend the X-Header-From line before "From:" because I could imagine that "To:" will be omited if the message is addressed to only BCCs.
    And I think on the second line of your header checks, the pipe symbol should be escaped, but I'm not sure. I'd put it on separate lines with the same effect, just to be sure:
    Code:
    /^To: (.*)/ PREPEND X-Header-From: journaling@xyz.com
    /^Cc: (.*)/ PREPEND X-Header-To: $1
    /^Bcc: (.*)/ PREPEND X-Header-To: $1
    Also note the $1 substitution.

    But, hmm, I think that BCC is not part of the mail headers, BCCs get mentioned only in the SMTP communication when transporting the message.

    Also note that the effect of this would be adding these headers to EVERY message that flows through the MTA in or out, unless you use some other forms of filtering.
    Last edited by beli.sk; 05-23-2011 at 03:11 AM. Reason: Typo
    Michal Belica - IT consultant
    www.beli.sk

  6. #6
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default

    Thanks.

    Yes, I will add a filter when it's start working.

    I've changed the lines in header_checks but still only X-Header-From is getting reflected in final message header. No X-Header-To entry found.

  7. #7
    Join Date
    Apr 2011
    Location
    Slovakia
    Posts
    18
    Rep Power
    4

    Default

    Oh, I see, you'd only get the X-Header-To when the message contains CC or BCC. Try this:
    Code:
    /^From: (.*)/ PREPEND X-Header-From: journaling@xyz.com
    /^To: (.*)/ PREPEND X-Header-To: $1
    /^Cc: (.*)/ PREPEND X-Header-To: $1
    /^Bcc: (.*)/ PREPEND X-Header-To: $1
    But this means you'll have many X-Header-To lines, one for each of "To:", "Cc:" and "Bcc:" header line. If that's a problem you could do some more advanced logic in the header checks.
    Michal Belica - IT consultant
    www.beli.sk

  8. #8
    Join Date
    Mar 2011
    Posts
    131
    Rep Power
    4

    Default

    Alright. Got it. So, when I've CC then only I will get X-Header-To. It's confirmed.

    But I've kept one person in BCC. But I neither BCC address appended to X-Header-To nor another X-Header-To entry found.

    Do you think that postfix will check BCC header?

  9. #9
    Join Date
    Apr 2011
    Location
    Slovakia
    Posts
    18
    Rep Power
    4

    Default

    As I noted before, the BCC addresses are not put into the message headers (if they would, the recipients would be able to see them, defeating the purpose of BCC), so it's not possible to work on them as headers. At the moment I can't think of any trivial way to put them into a header apart from writing a filter program for postfix. But I wouldn't recomend doing so for the reason already mentioned.
    Michal Belica - IT consultant
    www.beli.sk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •