Postfix Filters and header_checks

Tyler Strickland tyler at tylers.org
Mon Aug 15 15:01:35 MDT 2005


On 08/15/05 13:57, Dennis wrote:
> Anybody know how to get a filter to work with postfix?
> 
> Here is what I want..
> 
> main.cf:
> 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:[127.0.0.1]:10024

amavisd-new is foo, the rest is bar.  amavisd-new references an entry in 
your master.cf 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 
master.cf entry:

127.0.0.1:10025 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=127.0.0.0/8
         -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.

--Tyler



More information about the PLUG mailing list