Postfix: Add Custom Header

The file /etc/postfix/header_checks does the trick.

It has to be included to first

vi /etc/postfix/

Add a line like

smtp_header_checks = regexp:/etc/postfix/header_checks

Save and exit the editor.


Now open the file header_checks and add your regexps.

Use the PREPEND operator to add a custom header to your emails.

The prepended text is output on a separate line, immediately before the input that triggered the PREPEND action.


/^From:/i PREPEND X-DKIM-Options: s=k1; [email protected]

This will add the line

X-DKIM-Options: s=k1; [email protected]

immediately before the line beginning with From:.

Add as many custom headers as you need. There are many more actions than PREPEND as explained in man 5 header_checks.


Rebuild the database with

postmap hash:/etc/postfix/header_checks


restart postfix

service postfix restart


If the postfix header_checks are not working or set twice, then propably receive_override_options are set incorrect, either in or in

grep -R receive_override_options /etc/postfix

Test also with

postconf -n