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

Re: header_checks PREPEND

Expand Messages
  • Sandy Drobic
    ... Prepend sets a new Subject header here. This is better done by your filter software. Header_checks can t set a subject header in relation to another check
    Message 1 of 7 , Nov 1, 2006
    • 0 Attachment
      nick@... wrote:
      > Hi,
      >
      > Im looking to prepend [SPAM] to the Subject: of mails that come in with a preassigned X-SpamReason: value of 1..4.
      >
      > main.cf:header_checks = pcre:/etc/postfix/header_checks
      >
      > And in header_checks:
      > /X-SpamReason: Yes, hits=([1..4]\.[0-9]*).*required/ PREPEND Subject: [SPAM]
      >
      > However this is overwriting the Subject completely, and Im just getting [SPAM] in the Subject of the mail
      > once its received.
      >
      > Any idea what I could be doing wrong ?

      Prepend sets a new Subject header here. This is better done by your filter
      software. Header_checks can't set a subject header in relation to another
      check on x-spamreason.

      You either need a filter for that or do it directly in your spamfilter.

      Sandy
      --
      List replies only please!
      Please address PMs to: news-reply2 (@) japantest (.) homelinux (.) com
    • nick@javacat.f2s.com
      ... I see, thanks for the explanation. Nick .
      Message 2 of 7 , Nov 1, 2006
      • 0 Attachment
        Quoting Sandy Drobic <postfix-users@...>:

        > nick@... wrote:
        > > Hi,
        > >
        > > Im looking to prepend [SPAM] to the Subject: of mails that come in with a preassigned X-SpamReason: value of 1..4.
        > >
        > > main.cf:header_checks = pcre:/etc/postfix/header_checks
        > >
        > > And in header_checks:
        > > /X-SpamReason: Yes, hits=([1..4]\.[0-9]*).*required/ PREPEND Subject: [SPAM]
        > >
        > > However this is overwriting the Subject completely, and Im just getting [SPAM] in the Subject of the mail
        > > once its received.
        > >
        > > Any idea what I could be doing wrong ?
        >
        > Prepend sets a new Subject header here. This is better done by your filter
        > software. Header_checks can't set a subject header in relation to another
        > check on x-spamreason.
        >
        > You either need a filter for that or do it directly in your spamfilter.

        I see, thanks for the explanation.

        Nick .
      • mouss
        ... you can use procmail|maildrop with formail|reformail. it is possible to with postfix but that would be overkill (run a specific smtpd as a content_filter,
        Message 3 of 7 , Nov 1, 2006
        • 0 Attachment
          nick@... wrote:
          > Quoting Sandy Drobic <postfix-users@...>:
          >
          >
          >> nick@... wrote:
          >>
          >>> Hi,
          >>>
          >>> Im looking to prepend [SPAM] to the Subject: of mails that come in with a preassigned X-SpamReason: value of 1..4.
          >>>
          >>> main.cf:header_checks = pcre:/etc/postfix/header_checks
          >>>
          >>> And in header_checks:
          >>> /X-SpamReason: Yes, hits=([1..4]\.[0-9]*).*required/ PREPEND Subject: [SPAM]
          >>>
          >>> However this is overwriting the Subject completely, and Im just getting [SPAM] in the Subject of the mail
          >>> once its received.
          >>>
          >>> Any idea what I could be doing wrong ?
          >>>
          >> Prepend sets a new Subject header here. This is better done by your filter
          >> software. Header_checks can't set a subject header in relation to another
          >> check on x-spamreason.
          >>
          >> You either need a filter for that or do it directly in your spamfilter.
          >>
          >
          > I see, thanks for the explanation.
          >

          you can use procmail|maildrop with formail|reformail.

          it is possible to with postfix but that would be overkill (run a
          specific smtpd as a content_filter, using the FILTER statement in place
          of your PREPEND. then that smtpd will have its own cleanup to modify the
          subject).

          That said, subject rewrite is more or less ugly. sometimes, a site
          misclassifies a message and tag the subject, then the recipient replies
          to forwards it... I already seen customer requests with a spam tag in
          the subject! fortunately, I don't rely on the subject...

          An alternative is to prepend specific headers. For recipients using
          imap, you can deliver to a Junk folder. Pop users can set filters on
          their MUAs based on the headers you prepend.
        • nick@javacat.f2s.com
          ... The postfix server in question simply passes inbound valid mail to our exchange server and passes outbound mail to an external mail service run by
          Message 4 of 7 , Nov 1, 2006
          • 0 Attachment
            Quoting mouss <usebsd@...>:

            > nick@... wrote:
            > > Quoting Sandy Drobic <postfix-users@...>:
            > >
            > >
            > >> nick@... wrote:
            > >>
            > >>> Hi,
            > >>>
            > >>> Im looking to prepend [SPAM] to the Subject: of mails that come in with a preassigned X-SpamReason: value of 1..4.
            > >>>
            > >>> main.cf:header_checks = pcre:/etc/postfix/header_checks
            > >>>
            > >>> And in header_checks:
            > >>> /X-SpamReason: Yes, hits=([1..4]\.[0-9]*).*required/ PREPEND Subject: [SPAM]
            > >>>
            > >>> However this is overwriting the Subject completely, and Im just getting [SPAM] in the Subject of the mail
            > >>> once its received.
            > >>>
            > >>> Any idea what I could be doing wrong ?
            > >>>
            > >> Prepend sets a new Subject header here. This is better done by your filter
            > >> software. Header_checks can't set a subject header in relation to another
            > >> check on x-spamreason.
            > >>
            > >> You either need a filter for that or do it directly in your spamfilter.
            > >>
            > >
            > > I see, thanks for the explanation.
            > >
            >
            > you can use procmail|maildrop with formail|reformail.
            >
            > it is possible to with postfix but that would be overkill (run a
            > specific smtpd as a content_filter, using the FILTER statement in place
            > of your PREPEND. then that smtpd will have its own cleanup to modify the
            > subject).
            >

            The postfix server in question simply passes inbound valid mail to our exchange server
            and passes outbound mail to an external mail service run by messagelabs, messagelabs
            then passes it on to the outside world.

            It's the messagelabs server that puts in the X-SpamReason header. I need to catch
            this X-SpamReason value and if it's >0 & <= 4 do nothing with it, just pass it
            onto exchange.

            If the X-SpamReason header value is > 4 & < 7 prepend the subject with [SPAM] and
            pass it to exchange as normal, letting the user set a rule in outlook for this if
            they wish.

            X-SpamReason > 7 will result in the mail getting redirected to a quarantine address
            in exchange.

            I've tried to google software that will let me do this, but I'm not having much luck.
            I had thought about setting up my own content_filter but like yourself I considered it
            overkill.

            Would procmail/maildrop work with the situation I described above ? I don't have any
            experience of procmail or maildrop.

            If anyone knows any software which will do what I'd appreciate a heads up. We aren't doing
            our own spam/virus scanning so I can't rewrite the subject with spamassassin.

            Thanks,
            Nick .
          • mouss
            ... yes. Here is a summary (with maildrop) - use transports to deliver mail for @domain.example to maildrop - maildrop * checks the spam header. * maildrop
            Message 5 of 7 , Nov 1, 2006
            • 0 Attachment
              nick@... wrote:
              > The postfix server in question simply passes inbound valid mail to our exchange server
              > and passes outbound mail to an external mail service run by messagelabs, messagelabs
              > then passes it on to the outside world.
              >
              > It's the messagelabs server that puts in the X-SpamReason header. I need to catch
              > this X-SpamReason value and if it's >0 & <= 4 do nothing with it, just pass it
              > onto exchange.
              >
              > If the X-SpamReason header value is > 4 & < 7 prepend the subject with [SPAM] and
              > pass it to exchange as normal, letting the user set a rule in outlook for this if
              > they wish.
              >
              > X-SpamReason > 7 will result in the mail getting redirected to a quarantine address
              > in exchange.
              >
              > I've tried to google software that will let me do this, but I'm not having much luck.
              > I had thought about setting up my own content_filter but like yourself I considered it
              > overkill.
              >
              > Would procmail/maildrop work with the situation I described above ? I don't have any
              > experience of procmail or maildrop.
              >
              >

              yes. Here is a summary (with maildrop)
              - use transports to deliver mail for @... to maildrop
              - maildrop
              * checks the spam header.
              * maildrop gets the subject
              * if spam, maildrop runs reformail to change the subject
              * maildrop forwards mail to foo@...
              - use transports to forward @... to your exchange server
              - use generic to rewrite @... to @...

              but this sounds like "trying to avoid a content_filter at all expenses"!
              see below.
              > If anyone knows any software which will do what I'd appreciate a heads up. We aren't doing
              > our own spam/virus scanning so I can't rewrite the subject with spamassassin.
              >
              >

              you could run SA with just one rule: match the X-SpamReason header and
              score it enough to trigger sbject rewrite. but there is no need to use
              SA just for this.

              Instead,
              - write a script to check the spam header and modify the subject accordinly
              - use smtpprox to run the script

              If you are not confortable writing scripts or maildrop/procmail recipes,
              here is a postfix-only way. Convoluted but...


              - add an smtpd (let's say on 127.0.0.1:10099) and a corresponding
              cleanup to your master.cf. This cleanup has a header check that always
              tags the subject:
              /^Subject: (.*)/ REPLACE Subject: [Spam] $1

              - In the "standard" header_checks, use
              /X-SpamReason: Yes, hits=([1..4]\.[0-9]*).*required/ FILTER
              scan:[127.0.0.1]:10099
              where scan is defined as a filtering transport in master.cf

              - the smtpd on 10099 has no content_filter, does no unknown recipient
              validation, ... (see the FILTER_README for examples of configuration.
              copy options of the smtpd on 10025 from there).
            • Nick Lunt
              ... Mouss, I can t thank you enough for taking the time to explain all that. It s very much appreciated. Nick .
              Message 6 of 7 , Nov 1, 2006
              • 0 Attachment
                mouss wrote:
                > nick@... wrote:
                >> The postfix server in question simply passes inbound valid mail to
                >> our exchange server
                >> and passes outbound mail to an external mail service run by
                >> messagelabs, messagelabs
                >> then passes it on to the outside world.
                >>
                >> It's the messagelabs server that puts in the X-SpamReason header. I
                >> need to catch
                >> this X-SpamReason value and if it's >0 & <= 4 do nothing with it,
                >> just pass it
                >> onto exchange.
                >>
                >> If the X-SpamReason header value is > 4 & < 7 prepend the subject
                >> with [SPAM] and
                >> pass it to exchange as normal, letting the user set a rule in outlook
                >> for this if
                >> they wish.
                >>
                >> X-SpamReason > 7 will result in the mail getting redirected to a
                >> quarantine address
                >> in exchange.
                >>
                >> I've tried to google software that will let me do this, but I'm not
                >> having much luck.
                >> I had thought about setting up my own content_filter but like
                >> yourself I considered it
                >> overkill.
                >>
                >> Would procmail/maildrop work with the situation I described above ? I
                >> don't have any
                >> experience of procmail or maildrop.
                >>
                >>
                >
                > yes. Here is a summary (with maildrop)
                > - use transports to deliver mail for @... to maildrop
                > - maildrop
                > * checks the spam header.
                > * maildrop gets the subject
                > * if spam, maildrop runs reformail to change the subject
                > * maildrop forwards mail to foo@...
                > - use transports to forward @... to your exchange server
                > - use generic to rewrite @... to @...
                >
                > but this sounds like "trying to avoid a content_filter at all
                > expenses"! see below.
                >> If anyone knows any software which will do what I'd appreciate a
                >> heads up. We aren't doing
                >> our own spam/virus scanning so I can't rewrite the subject with
                >> spamassassin.
                >>
                >>
                >
                > you could run SA with just one rule: match the X-SpamReason header and
                > score it enough to trigger sbject rewrite. but there is no need to use
                > SA just for this.
                >
                > Instead,
                > - write a script to check the spam header and modify the subject
                > accordinly
                > - use smtpprox to run the script
                >
                > If you are not confortable writing scripts or maildrop/procmail
                > recipes, here is a postfix-only way. Convoluted but...
                >
                >
                > - add an smtpd (let's say on 127.0.0.1:10099) and a corresponding
                > cleanup to your master.cf. This cleanup has a header check that always
                > tags the subject:
                > /^Subject: (.*)/ REPLACE Subject: [Spam] $1
                >
                > - In the "standard" header_checks, use
                > /X-SpamReason: Yes, hits=([1..4]\.[0-9]*).*required/ FILTER
                > scan:[127.0.0.1]:10099
                > where scan is defined as a filtering transport in master.cf
                >
                > - the smtpd on 10099 has no content_filter, does no unknown recipient
                > validation, ... (see the FILTER_README for examples of configuration.
                > copy options of the smtpd on 10025 from there).

                Mouss, I can't thank you enough for taking the time to explain all that.
                It's very much appreciated.

                Nick .
              Your message has been successfully submitted and would be delivered to recipients shortly.