I have Postfix running with a number of smtpd processes configured in master.cf like this:
# Internet facing one
1.2.3.4:25 inet n - y - - smtpd
-o ... # internet-only overrides
# Internal facing one
10.0.0.1:10026 inet n - y - - smtpd
-o ... # internal-only overrides
Now, I'd like to add a single header, with static name and value, to incoming mail depending on which smtpd it was received on.
Example:
X-Gert-Postfix-Received-From: the evil internet
My options considered:
Add the
header_checks
option and use thePREPEND
action in the file.Nearly there, but:
- It requires to match an existing header and will then add one more on subsequent matches.
- I don't always have a certain header present already, perhaps even a
From
is missing, for example. - In case you have existing
header_checks
, there's no easy way to stack twoheader_check
files, I think.
Build a custom app that uses the Milter protocol and hook that up to Postfix with
smtpd_milters
.Of course, this will work. I can inspect the mail in my own app, then inject the header there. Seems over-engineering for a simple task like adding a header. Additionally, it requires extra maintenance with the need to run another daemon app, quite some boilerplate code, etc.
As suggested in a comment, use
check_recipient_access
(related Q).Same downsides as
header_checks
(see 1).
I feel like I'm missing something simple. Anyone got a better idea?