I am trying to add a custom header to all messages handled by my postfix server. I tried using a guide on the internet without any luck.
In my master.cf i added:
-o smtp_header_checks=regexp:/etc/postfix/test_tag_header
test_tag_header: Prepend X-Mailgun-Tag: testing123
made sure I restarted postfix
I did a few tests to yahoo mail which has a full headers option. The headers i added did not show up.
My goal is to add a custom header with a random value so that I can later parse the message using mailgun.org's api.
X-Mailgun-Tag: randomvalue (similar to url shortener)
Based upon the answer from ank this is what i have so far: main.cf
smtp_recipient_restrictions = check_recipient_access proxy:mysql:/etc/postfix/mailgun_header.mysql
mailgun_header.mysql
user = vmail
password = mypass
hosts = 127.0.0.1
port = 3306
dbname = vmail
query = select CONCAT(prefix, MD5(RAND())) as 'check_recipient_access' from mailgun_tokens where prefixID = 1;
when i try to restart postfix i get thef ollowing errors:
/usr/sbin/postconf: warning: /etc/postfix/main.cf: unused parameter: smtp_recipient_restrictions=check_recipient_access proxy:mysql:/etc/postfix/mailgun_header.mysql
*
The sql query works fine through MYSQL and returns a row with a random number.