> On 4/4/2011 9:54 PM, email builder wrote:

> > 
> > OK, sorry  again.  I had assumed because you can turn off header checking by
> >  using receive_override_options, you could also override (change) them.
> 
> It  is possible to override header_checks by defining a different  
>cleanup_service_name
> for smtpd, then defining that cleanup service with a  header_checks override. 
>  
>This
> can get pretty messy, you can find examples  in the list archives.

Mmm, thanks.  I just happened to find this idea late yesterday when researching 
this issue.  It's interesting, but it looks like it ultimately isn't necessary.

> The better solution is to use multiple  instances.  All postfix versions 
>support multiple
> instances.  Newer  versions include tools to make multiple instance 
>creation/maintenance
> easier.

I've been trying to avoid this, but we might end up having to go this route.  
Thanks for the encouragement.

> > Reading smtpd(8) manpage, it does seem like  smtpd_data_restrictions would 
> > be 
>a
> > good place to be able to inspect the  mail headers and use the PREPEND to 
>insert
> > a new header.  But I was  using check_client_access to do so, and that only 
>seems
> > to inspect the  client address and related information....  but looking 
>through
> > the  list of restrictions I cannot understand which one allows the 
> > inspection  
>of
> > the message data itself.
> 
> The postfix smtpd_*_restrictions  allow you to inspect envelope information.
> 
> To inspect message header or  body contents, postfix provides header_checks,
> body_checks, and an interface for  an external content filter, proxy, or  
>milter.
> http://www.postfix.org/CONTENT_INSPECTION_README.html

This jives with what I'd understood from the documentation - 
smtp_*_restrictions 
let you check the envelope only, not the headers/body.  But I was confused by 
some people giving examples of how to add headers with PREPEND actions during 
some smtpd_*_restrictions checks.  It turns out (from my testing, but I can't 
find this in the docs) that you can still use PREPEND to add a header even 
though you're looking at certain envelope data.  


The other confusing bit was what to test for -- since you're looking at the 
envelope, you can't just look for /^From:/ for example.  It's not there.  But 
since I'm trying to unconditionally add a header, the trick seems to be that 
what's there does not matter (just use /^/), and in that sense, the envelope 
check for, say, sender, is perfect - it's just one line (so your header doesn't 
get added more than once).  So all you have to do is:

master.cf smtpd process entry:
       -o 
smtpd_data_restrictions=check_sender_access,pcre:/etc/postfix/add_my_header

/etc/postfix/add_my_header:
   /^/   PREPEND X-My-Header: Hello_world

Easier than I thought.  Now, PLEASE don't take this the wrong way, but I'm 
wondering why no one offered this solution.  Am I doing something I should not 
be doing?

Reply via email to