Below you will find a description how to redirect a message based on sender and subject. We will use MSH Traffic Policy milter application which integrate with Postfix, Sendmail and Zimbra.
After installing server and desktop module we can start to create a rule which will do what we need.
Create a Rule
Start the application and connect to the mail server. Select Rules node and click Add Group button. We need to add rules group which will contain our new rule. Name it like Redirect Rules. Select our new Redirect Rules node and on the right panel click Add Rule button. Rule wizard will open.
With wizard we will define actions, conditions, exceptions and rule name. With Actions we will redirect our message, conditions and exceptions will help us to match messages which should be redirected.
We will begin with conditions. In our scenario we want to redirect messages which are sent from @xcomany.com domain and include INVOICE phrase in the message subject. The word “and” is important here, because messages which don’t have INVOICE text in subject or are not from specified domain should go through without change.
Switch to Conditions tab, click Add button and choose Message Sender – Email Address menu. Select Wildcards from drop down menu option and put *@xcompany.com text in Email addresses text input. Click OK button.
Sender condition added, now is time for the message subject. Click Add button and this time choose Message Subject or Body contains menu. Select Subject option in Search from drop down menu. Choose Wildcards in Match text with option. Put *INVOICE* text in Word or Phrase text input. Click OK button.
At bottom of the rule wizard on Conditions tab select All condition met option.
Choose an Action
Go back to Actions page. Now we will define the action which should be taken on messages which will met our conditions.
To forward message we need to apply to actions on the message. Add Envelope Recipient and Add Message Header. It’s because envelope recipient will only modify recipients address list without adding a MIME message header. Recipient will receive a message but he/she will not see own email address in TO/CC/BCC message fields.
Click Add button and choose Add Envelope Recipient menu. Provide an email address which should receive a copy of the message. For this scenario we will use email@example.com example address. Now click Add button and choose Add Message Header menu. Put CC text as Header Name and firstname.lastname@example.org in Header Value field. Click OK button.
We had defined condition criteria to match messages and actions which should be taken. Switch to Name tab, give a rule name, like Redirect Messages from @xcompany.com with INVOICE in subject. Click OK button to close rule wizard.
Save and Verify
To apply changes click Save All button.
Now when messages with specified phrase in subject and sent from @xcompany.com domain will go through mail server they will automatically be also send to email@example.com address. Original recipient of the message also will get the message.
To learn more visit MSH Traffic Policy website.