Rejecting emails with certain types of attachments
![](https://secure.gravatar.com/avatar/15ec34030c4df47f2238827b2681988a.jpg?s=120&d=mm&r=g)
Hi list,
is it possible to automatically reject emails that have attachments with certain MIME types (e.g., application/msword, …)?
Since there are so many types of files that are unsafe, I also wonder whether it is possible to specify a white list of safe MIME types (e.g., application/PDF) and to reject everything else. Is that possible?
I did some searching but only found solutions for automatically stripping attachments, which is not what I want.
Thank you,
Titus
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 02/29/2016 03:53 PM, Titus von der Malsburg wrote:
You can remove such attachments either by "blacklisting" bad MIME types (Content filtering -> filter_mime_types) or "whitelisting" good ones (Content filtering -> pass_mime_types), but you say you don't want that, and you want to reject (or discard might be better) the mail outright.
You might consider your MTA's features for this, e.g., Postfix's mime_header_checks. Then the MTA can reject the mail at incoming SMTP which is a better solution.If your requirements are more complex you might still use a milter (or some coding in exim).
In Mailman, your only option is Privacy options... -> Spam filters -> header_filter_rules (see the 'details' for this in the admin web UI.
For example, a rule with a regexp like
^Content-Type:.*application/(?!pdf)
and an action of Discard should discard any message with a MIME part of mail type application and sub part not starting with 'pdf'. See <https://docs.python.org/2/library/re.html#regular-expression-syntax>.
If you try this, I suggest initially setting your rule actions to hold until you are confident that your rules do what you want.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 02/29/2016 03:53 PM, Titus von der Malsburg wrote:
You can remove such attachments either by "blacklisting" bad MIME types (Content filtering -> filter_mime_types) or "whitelisting" good ones (Content filtering -> pass_mime_types), but you say you don't want that, and you want to reject (or discard might be better) the mail outright.
You might consider your MTA's features for this, e.g., Postfix's mime_header_checks. Then the MTA can reject the mail at incoming SMTP which is a better solution.If your requirements are more complex you might still use a milter (or some coding in exim).
In Mailman, your only option is Privacy options... -> Spam filters -> header_filter_rules (see the 'details' for this in the admin web UI.
For example, a rule with a regexp like
^Content-Type:.*application/(?!pdf)
and an action of Discard should discard any message with a MIME part of mail type application and sub part not starting with 'pdf'. See <https://docs.python.org/2/library/re.html#regular-expression-syntax>.
If you try this, I suggest initially setting your rule actions to hold until you are confident that your rules do what you want.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Mark Sapiro
-
Titus von der Malsburg