Postfix Filters and header_checks

kirk kirk at
Mon Aug 15 16:12:16 MDT 2005

I use amavisd-new and it works just great.
Also, on another note please be very carefull using /Match Something/ 
FILTER ??:??
I created an endless loop the other day when the message_id of an email was 
caught by a header_check
I had was checking for /sex/ instead of something like /^Subject: sex/

However, I use the virtual user table, and the alias table to filter any 
emails that come in ending in

/^(.*)@emailadmin\.com$/                emailadmin+$1 at

emailadmin: "| perl /var/email_admin.i $EXTENSION"

let me know if this is something like what you want and I will be happy to 
explain further.

- Kirk Cerny

----- Original Message ----- 
From: "Tyler Strickland" <tyler at>
To: "Provo Linux Users Group Mailing List" <plug at>
Sent: Monday, August 15, 2005 3:01 PM
Subject: Re: Postfix Filters and header_checks

On 08/15/05 13:57, Dennis wrote:
> Anybody know how to get a filter to work with postfix?
> Here is what I want..
> header_checks=/etc/postfix/header_checks
> header_checks:
> /Match Something/  FILTER ??:??
> All the documentation I find for the header_checks just says foo:bar
> where I put ??:??.  I just want to execute a script with the mail as the
> input and then have the mail delivered unaltered.  So what is foo:bar
> supposed to really be?  The docs/man pages say it's
> transport:destination but I'm having trouble figuring out how to make
> transport:destination into path/args for my script.
> Any thoughts?

As mentioned in another reply, the setup is the same as for
content_filter.  My setup for content_filter is thus:

content_filter = amavisd-new:[]:10024

amavisd-new is foo, the rest is bar.  amavisd-new references an entry in
your file.  Mine, for example, is:

amavisd-new     unix    -       -       n       -       2       lmtp
         -o lmtp_data_done_timeout=1200s
         -o disable_dns_lookups=yes

As you can see, postfix passes the message to amavisd-new via LMTP.
Amavisd-new then scans the message (using clamav) and returns clean
messages to a smtpd process listening on port 10025 as started by this entry: inet    n       -       n       -       -       smtpd
         -o content_filter=
         -o local_recipient_maps=
         -o relay_recipient_maps=
         -o smtpd_restriction_classes=
         -o smtpd_client_restrictions=
         -o smtpd_helo_restrictions=
         -o smtpd_sender_restrictions=
         -o smtpd_recipient_restrictions=permit_mynetworks,reject
         -o mynetworks=
         -o strict_rfc821_envelopes=yes

That smtp process sends the message on to its final destination, be that
locally (though your mail delivery agent (MDA)) or externally.

If you're only concerned about incoming messages, another option you may
want to look into is sending the message to your filter using your MDA,
which is probably procmail or maildrop.  They both provide ample
functionality for passing a message to an external filter.  I can walk
you through setting up the filter in Maildrop if you like.  I'm sure
others here have procmail experience they can contribute.

| This has been a P.L.U.G. mailing. |
|      Don't Fear the Penguin.      |
|  IRC: #utah at   |

More information about the PLUG mailing list