adding a header without PREPEND?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

adding a header without PREPEND?

lmunro
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.

Thanks for your help,
Louis


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: adding a header without PREPEND?

Noel Jones-2
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.
>
> Thanks for your help,
> Louis
>
>

PREPEND is the action to add a header; the way you are doing
it is fine.  And there isn't any other action that adds custom
headers.

It's usually better to add custom headers under
smtpd_data_restrictions - otherwise with multi-recipient mail
you may get one header added for each recipient.

--
Noel Jones
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: adding a header without PREPEND?

mouss-2
In reply to this post by lmunro
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.
Loading...