Wednesday, April 3, 2013

Stripping/detaching attachments from messages

In MSH Traffic Policy, you can use attachment filtering to apply filters at the server level to control the attachments that users receive. Attachment filtering is increasingly important in today's environment, where many attachments contain harmful viruses or inappropriate material that may cause significant damage to the user's computer or to the organization.

This milter will remove attachments from the email messages and replace them with links to the attachments on ftp or network drive, allowing easy access to files while keeping mailboxes smaller. Bare Postfix and Sendmail not provide this functionality out of the box, third party tool is needed.

Application provide Strip Attachments action which allows extracting any attachments from the incoming messages and save them to shared location. Filtering can be based on file name, file extension, mime type, file size or attachments count. You can delete attachments from all messages or only from emails specified by  scope of senders or recipients.

Built in attachments processor will skip digitally signed, encrypted and rights protected e-mail messages. If exporting attached files is not necessary then other actions can be used: 
  • block whole message and attachments
  • delete attachments but allow message through
  • silently delete message and attachments
  • reject email message

Using Strip Attachments action

Before we create our rule, template notification is needed. We can create the template in HTML or Plain Text format.

Select Templates tree node and click Add button. In template definition window provide name and body template, in HTML format provide html source code. In template body $MSGID variable can be used, it will be replaced with message identifier, it is used when creating separate directories for attachments.


After adding two template formats you will have result like this (Attachments Stripped html and plain text entries).


Now we can create our rule for archiving messages on network disk. Create rule group and add new rule. On Actions tab click button Add and select Strip Attachments action.


In Directory path field provide absolute path on server where to automatically save attachments. I.e /var/attachments. From Plain Text and HTML template choose our previously created templates. Click button OK.

On Conditions tab click button Add and choose Attachments count requirement. Provide your values. I have used grater or equal to 1 condition.


With this condition from all messages outgoing or incoming attachments will be stripped. So for real life scenario it is good idea to define other conditions, like detach attach only from incoming messages. See full list of available conditions and exceptions.

Define rule name and click button OK. Save all settings and you are ready to test rule.

Testing rule

Send from one user to another test message with couple of attachments. Below you will find result from our example. When recipient will click on provided link he will be redirected to our provided location (of course it should be configured as ftp or network share).


So if you need to remove, strip, detach, delete, dump attachments and insert advisory notice into message for recipient then MSH Traffic Policy will do it for you.

MSH Traffic Policy is a sophisticated heavy duty machinery for email processing, try it.