Blocking .exe email attachments

I have just completed a Virtualmin GPL install on a newly installed Debian Lenny, using the install script. Both virus and spam filtering are enabled under the features and plugins. I sent a test e-mail using usermin to one of the local accounts with an attached .exe file. The e-mail got delivered in the inbox with the .exe attachment. I assume since this wasn’t a real virus, clamav did not quarantine the e-mail. Unlike other content e-mail filters which quarantines file extensions based on what extensions you want blocked. Is my assumption correct?


ClamAV by itself doesn’t block files by their extension, it’s looking for specific kinds of viruses and trojans.

I’ve never tried to configure Clam to block files based on their extensions, though it might be simpler to do that from within Postfix using the mime header checks or similar.

However, if you’re just concerned about seeing that it’s working, you could try sending the eicar test virus, which is harmless, but Clam would still stop it:

If you just want extension based blocking, then you could save yourself a ton of resources. ClamAV is an anti-virus filter. It is not an extension-based blacklist. It would be a bug if it blocked an email just because it contained an exe file. (Also note than the anti-virus configuration in Virtualmin defaults to throwing the email away if it contains a virus. It does not “defang” the email and then deliver it. There is software that does that, like MIMEDefang, but that’s not suitable for the majority of non-technical users.)

Thank you both for the detailed answer, that was what I needed to know!

You can use /etc/procmailrc to do this sitewide.


Postfix uses ‘mime_header_checks’ to apply regular expressions to incoming e-mail. You can use the following expression to filter attachments based on extension:

REJECT 598 Attachment name "$2" may not end with ".$3"

(this example filters .bat, .exe and .scr, see references below for a list of other extensions you might want to consider blocking)



  • ^Content-(Disposition|Type).name\s*=\s*"?(..(bat|exe|scr))(?=)?"?\s(;|$)

As far as extension blocking is concerned, just wondering if anybody have experience with TXD spam filtering. I was lead to believe that TXD can block certain types of attachments like file extension exe nad .scr from getting through. But still a lot of email accounts still receive quite a bit amount of spam and one of them received an email that looks like a hoax/virus type and contains this .exe attachment. Can someone share any thoughts on this?