Loading ...
Sorry, an error occurred while loading the content.
 

Adding a header

Expand Messages
  • Ole Tange
    I have emails with subject: Subject: blah blah [Our Ref:XXX99999] I would like to have that changed to: X-Our-Ref: XXX99999 Subject: blah blah I can add the
    Message 1 of 3 , Jun 30, 2009
      I have emails with subject:

      Subject: blah blah [Our Ref:XXX99999]

      I would like to have that changed to:

      X-Our-Ref: XXX99999
      Subject: blah blah

      I can add the header with header_checks:

      /^Subject: .*(\[Our Ref:[A-Z]*[0-9]*\])$/ PREPEND X-Our-Ref: $1

      I can change the subject with header_checks:

      /^Subject: (.*)\[Our Ref:[A-Z]*[0-9]*\](.*)/ REPLACE Subject: $1$2

      But it seems I cannot do both. According to man header_checks PREPEND
      and REPLACE "inspect the next input line", which will explain why this
      does not work. As far as I can tell I cannot have 2 PREPEND acting on
      the same header.

      Is there a work-around for this?


      /Ole
    • Noel Jones
      ... Not inside postfix. As you ve found, only one action is allowed per header. You can pass mail through postfix twice (just use postfix as a content_filter)
      Message 2 of 3 , Jun 30, 2009
        Ole Tange wrote:
        > I have emails with subject:
        >
        > Subject: blah blah [Our Ref:XXX99999]
        >
        > I would like to have that changed to:
        >
        > X-Our-Ref: XXX99999
        > Subject: blah blah
        >
        > I can add the header with header_checks:
        >
        > /^Subject: .*(\[Our Ref:[A-Z]*[0-9]*\])$/ PREPEND X-Our-Ref: $1
        >
        > I can change the subject with header_checks:
        >
        > /^Subject: (.*)\[Our Ref:[A-Z]*[0-9]*\](.*)/ REPLACE Subject: $1$2
        >
        > But it seems I cannot do both. According to man header_checks PREPEND
        > and REPLACE "inspect the next input line", which will explain why this
        > does not work. As far as I can tell I cannot have 2 PREPEND acting on
        > the same header.
        >
        > Is there a work-around for this?

        Not inside postfix. As you've found, only one action is
        allowed per header.

        You can pass mail through postfix twice (just use postfix as a
        content_filter) and do the PREPEND first time through, and
        munge the Subject: the second time (requires separate cleanup
        services in master.cf for different header_checks; see the
        archives). If you're already using a content_filter, you get
        this for free.

        Maybe there's a content_filter or milter that can do what you
        need; mimedefang is a first guess.

        -- Noel Jones
      • LuKreme
        ... Run it through procmail, it s trivial. -- Naked blonde walks into a bar with a poodle under one arm, and two-foot salami under the other. The bartender
        Message 3 of 3 , Jun 30, 2009
          On 30-Jun-2009, at 06:11, Ole Tange wrote:
          > I have emails with subject:
          >
          > Subject: blah blah [Our Ref:XXX99999]
          >
          > I would like to have that changed to:
          >
          > X-Our-Ref: XXX99999
          > Subject: blah blah

          Run it through procmail, it's trivial.


          --
          Naked blonde walks into a bar with a poodle under one arm, and
          two-foot salami under the other. The bartender says, I guess
          you won't be needing a drink. Naked lady says
        Your message has been successfully submitted and would be delivered to recipients shortly.