Change the subject line for specific recipient

There is many ways to modify the message subject in Postfix and Sendmail based on the message recipient, but the simplest way is to use milter, like MSH Traffic Policy. This software can do a lot of more than change and rewrite subject, you can: take care of attachments, block spam, manage message headers and many more.

So lets see how to create a simple rule to modify the message subject.

Add new rule by clicking Add Rule button.

When rule wizard will open, on Actions tab click Add button and choose from menu Modify Message Subject position.

Define a new subject for the message, if you would like to add the original message subject use $SUBJECT variable.

If you would like to rewrite subject only for one user then on Conditions tab click Add button and choose Message Recipient position.

Enter recipient email address (like john.doe@host.local) and choose in which field to search for this recipient. We would like to change the message subject when our defined recipient is in TO or CC field. So select in Search address field in TO and CC field option.

On the Name tab define name for new rule, ie. Rewrite subject for user john.doe@sendmail.local and then click OK button.

When you create new rule click Save All button and you are ready to test your configuration.

To learn more visit MSH Traffic Policy website.

Lukasz is a software developer and owner of MSH Software company which builds email processing tools for Microsoft Exchange, Zimbra Collaboration Suite and Postfix. He specializes in server, desktop and web applications written in Java, .NET and C++.