We have an SMTP relay (postfix) where we need to rewrite headers on the fly based on certain criteria:
if> header contains x-custom-header: type 1
and if> to: @customer1.com
rewrite> from: <no-reply@mycompany.com>
to from: Friendly Name <friendly@mycompany.com>
Currently I'm using 3 instances of postmulti just for once client, with a header_check for each component of the ruleset.
But this approach will spawn / require a new instance for each rule due to restrictions in postfix where you can't have a header check for both a TO and FROM field in the same rule.
Question is: how do I scale this in an effective manner? Is there a better way to format / utilize the header checks.
Or are there alternative systems to easily manage advanced rulesets for header rewrites in an SMTP relay, like maybe through a gui?
Requirements will be to have multiple rules for at least three x-custom-headers with multiple clients.
Postfix Config: Instance 1
#main.cf instance 1:
...
header_checks = pcre:/etc/postfix/header_checks
multi_instance_wrapper = ${command_directory}/postmulti -p --
multi_instance_enable = yes
multi_instance_directories = /etc/postfix-instance2 /etc/postfix-instance3
...
#header_checks instance 1
/^x-custom-header: type 1/ FILTER smtp:127.0.0.1:10025
#need to add this next /^x-custom-header: type 2/ FILTER smtp:127.0.0.1:10026
#need to add this next /^x-custom-header: type 3/ FILTER smtp:127.0.0.1:10027
Instance 2
#master.cf instance 2
127.0.0.1:10025 inet n - n - - smtpd
#main.cf instance 2
...
queue_directory = /var/spool/postfix-instance2
data_directory = /var/lib/postfix-instance2
header_checks = pcre:/etc/postfix-instance2/header_checks
multi_instance_name = postfix-instance2
multi_instance_enable = yes
...
#header_checks instance 2
/^To: (.*)@customer1.com/ FILTER smtp:127.0.0.1:10028
Instance 3
#master.cf instance 3
127.0.0.1:10028 inet n - n - - smtpd
#main.cf instance 3
...
queue_directory = /var/spool/postfix-instance3
data_directory = /var/lib/postfix-instance3
header_checks = pcre:/etc/postfix-instance3/header_checks
multi_instance_name = postfix-instance3
multi_instance_enable = yes
...
#header_checks instance 3
^From: (.*?)@mycompany.com/ REPLACE From: Friendly Name <friendly@mycompany.com>