Tuesday, July 1, 2014

Postfix - Automatically add attachments to specified emails

Postfix is a mail transfer agent (MTA), it's job is to handle the delivery of the mail, picking it up and sending it to the next point on it's route. Like postal worker, whose job is to take an envelope and carry it to the recipient. But sometimes you need to extend it's functionality with some other job, like adding attachments to only specified email messages.

MSH Traffic Policy it's a milter which extends basic MTA functionality with powerful tools.

Add attachment to outgoing mails


Think about task when you need to add PDF file to each email message which is going to @gmail.com recipient. There is only one answer Recipient Condition with Add Attachment action.

Message Recipient condition and Add Attachment action


After defining rule with these condition and action, mail which are going to @gmail.com recipient will be send with an attachment.

If you need to:
  • manipulate attachments and remove, strip and count them, 
  • manipulate sender and recipients, block messages, and filter using keywords 
  • add disclaimers 
  • and many more
you should learn more about MSH Traffic Policy.