OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: adding a header without PREPEND?

From: mouss (moussnetoyen.net)
Date: Thu May 22 2008 - 16:28:04 CDT


Louis Munro wrote:
> Hi fellow postmasters,
> I want to add a header to all mail processed by postfix to be able to
> sort it using procmail based on which server received it (this postfix
> server is a smarthost). The procmail scripts will be used (and maybe
> written) by people who are not familiar with email headers and so I
> want to make it as easy as possible for them to match the condition.
>
> I am currently using this:
>
> in main.cf:
> smtpd_client_restrictions =
> check_client_access cidr:/etc/postfix/maps/add_headers.cidr
>
> in /etc/postfix/maps/add_headers.cidr:
> 0.0.0.0/0 PREPEND X-MTA-RECEIVED: server.example.com
>
>
> Which seems to work well enough, the header is added above the most
> recent "Received:" header making it easy to match with procmail.
>
> But I am left wondering if there isn't an easier way to do it.
> Is there a way to add a header line that can be configured outside of
> the usual access tables? Since this is to be done for all messages I
> would ideally like to be able to do it outside of the restrictions if
> only to keep them as simple as possible and avoid any possible
> conflict between PREPEND, REJECT, DUNNO and so on.
>
> Any ideas? This is for postfix 2.2.10.
>

In principle, you don't need to add a header, since postfix will add a
Received header of the form

Received: from ... (...) by $server (Postfix) ...

so you can get the server here.

but if you to make it easy for procmail developpers, then PREPEND seems
the right way to go.

As Noel says, put it in data restrictions to avoid multiple prepend
actions when mail is sent to multiple recipient.