Azimout's Linux weblog

Prepend label to message subject with Postfix

with 4 comments

So, you’re running Postfix on your home server and using a smarthost to forward those messages to your real email address. But you want to be able to somehow easily identify those messages, e.g. by prepending some sort of [MY_LABEL] to each message’s subject line.

To do that, use Postfix’s header_checks mechanism.

  1. Add the following line to your /etc/postfix/
    header_checks = regexp:/etc/postfix/header_checks
  2. Create file /etc/postfix/header_checks with the following regular expression:
    /^Subject: (.*?)$/ REPLACE Subject: [MY_LABEL] $1

Written by azimout

02/01/2013 at 21:55

Posted in Howto

4 Responses

Subscribe to comments with RSS.

  1. Nice, easy-to-use writeup. Is there a way to add things like the current date to the subject? I’ve tried various combinations, but no luck…


    27/05/2015 at 19:21

  2. Thanks a lot!

    Simon Elbaz

    26/01/2016 at 15:04

  3. Awesome !!!


    04/06/2017 at 08:45

  4. Thank you! Since headers are case-insensitive, you should add “/i” to the regexp:

    /^Subject: (.*?)$/i REPLACE Subject: [MY_LABEL] $1

    Ivan Zahariev

    10/10/2017 at 18:41

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: