This document describes a solution to match on attachment file size in a filter condition.
Is there a filter condition matching on the file size of single attachment(s) instead of message size?
On the Cisco Email Security Appliance (ESA), there is no option in Message Filters or Content Filters to match on attachment file size in a filter condition. The only size related condition is the Message Size condition, which is taking the size of the complete message into consideration.
The solution is to make use of the $filesizes Action Variable, which contains a comma separated list of the file size of all attachments contained in a message. If a X-header is added to the message with the value of $filesizes then a Regular Expression (RegEx) can be constructed to match if any of the contained numbers (file sizes) exceeds a certain value.
The example below shows the setup of a content filter that drops a message if the size of attachment(s) equals to or exceeds 10000 bytes:
- Create a Content Filter to add the value of the "$filesizes" action variable in a X-header:
- Create another Content Filter to match on the file sizes contained in the new X-header, and drop the message if any of the files equals to or exceeds 10000 bytes:
- Enable the two new Content Filters on all relevant Mail Policies in the above shown order.