Add header to outgoing email with postfix

emailpostfix

Can someone please provide an example on how to add a

Precedence: bulk

header to all outgoing emails using postfix.

I would like to know what file(s) to create or edit and what I should put in them. And also what to do to make postfix read in the new configuration.

I have read quite a bit of documentation but it seems to expect a high level of familiarity with postfix. All I have gathered so far is that it may have something to do with /etc/postfix/main.cf and somehow add a PREPEND statement.

Note that mucking about with postfix (and email in general) is way out of my comfort zone.

Best Answer

Unfortunately, this isn't super straightforward in postfix, but certainly doable.

/etc/postfix/main.cf, set header_checks to:

header_checks = regexp:/etc/postfix/my_custom_header

Then create /etc/postfix/my_custom_header and put this regular expression in it:

/^Content-Transfer-Encoding:/i PREPEND Precedence: bulk 

Then restart postfix - depends on your distro, but most likely you can restart it with service postfix restart or /etc/init.d/postfix restart.

Thats about it. What this does is that postfix will find the Content-Transfer-Encoding: header in the email and add your Precedence: bulk line right before it, hence the PREPEND action.

Now, this assumes that the Content-Transfer-Encoding header actually exists in the emails. You may want to take a look at the headers on a typical outgoing email and find a good one to match upon. You can get crazy with the regex to suit your needs.

Related Question