Monday, January 11, 2016

Postfix: Rewrite Message Subject Based on Recipient

Problem

Some time ago user had a problem because his company switched to a new email-to-fax service. They had a security implementation that require to append to each email sent to them a fax number. Number must be added at the beginning of the message subject. He wanted to automate this step so users don't need to remember and manually add number to subject.

So the requirement is that messages which are sent to fax@super-service.com must have subject in format:

123-555-789: Message subject.

Where Message subject is an original message subject before modifications and 123-555-789 is a fax number.

Solution 

We need to create a rule with Message Recipient condition and Modify Message action.

  1. Go to [Server] > Rules > Default Rules and click Add Rule button. 
  2. In new opened window, go to Actions tab and click Add button, choose Modify Message Subject menu. 
  3. Now define how subject will look like after rewrite. Based on our requirement is should be in 123-555-789: $SUBJECT format. Were $SUBJECT is a value which will be replaced with message subject. 
  4. Go to Conditions page and click Add button, select Message Recipient menu. 
  5. Enter a recipient email address: fax@super-service.com. Select in which fields address will be searched. 
  6. On the Name page set a rule name, it should be a name which briefly describe actions made by this rule, for example: Modify subject for fax service
  7. Click OK button, then Save All to save current settings. 
Rule wizard provide many variations of actions, ie. Modify Message Subject.

Summary 

Now when someone will send a message to fax service email address to the message subject fax number will be added.

MSH Traffic Policy is a milter application for popular mail servers which extends theirs mail flow. To learn more about MSH Traffic Policy for Zimbra, Postfix and Sendmail visit official website.