Postfix Filters and header_checks

Dennis devel at muhlesteins.com
Tue Aug 16 08:48:47 MDT 2005


kirk wrote:

>Postfix can reroute messages to another recipient using the REDIRECT action 
>if
>a pattern in the headers and the body matches.
>
>/Subject:.*example/
>    REDIRECT test at example.com
>Then using the virtual and alias table make example.com pipe to your script
>
>/etc/virtual
>/^(.*)@example\.com$/                emailadmin+$1 at domainname.com
>
>/etc/aliases
>emailadmin: "| perl /var/email_admin.i $EXTENSION"
>
>$EXTENSION ends up being 'test'
>
>Does this help?
>
>  
>
That's getting pretty close to what I want.  I play around with it and
see if it solves the problem.  I do have to worry about legit emails (ie
replys) not being lost etc.

>
>----- Original Message ----- 
>From: "Dennis" <devel at muhlesteins.com>
>To: "Provo Linux Users Group Mailing List" <plug at plug.org>
>Sent: Monday, August 15, 2005 4:18 PM
>Subject: Re: Postfix Filters and header_checks
>
>
>kirk wrote:
>
>  
>
>>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
>>
>>/etc/virtual
>>/^(.*)@emailadmin\.com$/                emailadmin+$1 at domainname.com
>>
>>/etc/aliases
>>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
>>
>>
>>    
>>
>I'm actually not doing it for spam purposes.  I want to process emails
>that I send out that bounce back.  I can add a header to the email I
>send, and then getting email back I can simply run it through the script
>if the header matches and do some work to record the bounced email.
>
>I did get the header_checks to run the script, (foo:bar=filter:dummy)
>but it did create an infinite loop like you mentioned.  Another option I
>can get to work is to have the script process every email but check for
>the header. (I'd rather have postfix check that so I don't have to worry
>about it.)  So I'd be interested in learning how you avoid the infinite
>loop.
>
>Perhaps there is a better solution I'm missing.
>
>-Dennis
>
>  
>
>>----- Original Message ----- 
>>From: "Tyler Strickland" <tyler at tylers.org>
>>To: "Provo Linux Users Group Mailing List" <plug at plug.org>
>>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..
>>>
>>>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
>>.-----------------------------------.
>>| This has been a P.L.U.G. mailing. |
>>|      Don't Fear the Penguin.      |
>>|  IRC: #utah at irc.freenode.net   |
>>`-----------------------------------'
>>
>>.-----------------------------------.
>>| This has been a P.L.U.G. mailing. |
>>|      Don't Fear the Penguin.      |
>>|  IRC: #utah at irc.freenode.net   |
>>`-----------------------------------'
>>
>>
>>    
>>
>
>.-----------------------------------.
>| This has been a P.L.U.G. mailing. |
>|      Don't Fear the Penguin.      |
>|  IRC: #utah at irc.freenode.net   |
>`-----------------------------------' 
>
>.-----------------------------------.
>| This has been a P.L.U.G. mailing. |
>|      Don't Fear the Penguin.      |
>|  IRC: #utah at irc.freenode.net   |
>`-----------------------------------'
>  
>




More information about the PLUG mailing list