setup filetype and filename rules per domain

Gordon Colyn gordon at
Mon Aug 7 19:49:56 IST 2006


----- Original Message ----- 
From: "Julian Field" <mailscanner at>
To: "MailScanner discussion" <mailscanner at>
Sent: Monday, August 07, 2006 6:58 PM
Subject: Re: setup filetype and filename rules per domain

Hash: SHA1

Stephen Swaney wrote:
>> -----Original Message-----
>> From: mailscanner-bounces at [mailto:mailscanner-
>> bounces at] On Behalf Of Gordon Colyn
>> Sent: Monday, August 07, 2006 11:41 AM
>> To: mailscanner at
>> Subject: setup filetype and filename rules per domain
>> ITNT Banner CampaignIs there a way to setup filetype and filename rules
>> per
>> domain or user?
>> I have some client domains and users that want to accept .mp3 and .wav
>> files
>> and others that don't
>> Thanks
>> Gordon Colyn

In recent versions (version 4.49 and onwards) there are some new
configuration settings,
Allow Filenames
Deny Filenames
Allow Filetypes
Deny Filetypes
These are not as flexible as the filename.rules.conf and
filetype.rules.conf files, but you may find them easier to use and good
enough for your requirements.

For an example, let's say that domain wants to be able to email
files called "*.mp3" and "*.wav". You would still need to do similar
setups to stop the "filetype.rules.conf" file trapping movies in
general. But let's keep it simple for this example.

1) We need to tell MailScanner to create a ruleset for "Allow Filenames"
so we can vary the value of this setting depending on where the mail is
going to.
In MailScanner.conf, set
Allow Filenames = %rules-dir%/allow.filenames.rules

2) Create the ruleset. This just needs to allow *.mp3 and *.wav for mail
going to anyone at
In /etc/MailScanner/rules/allow.filenames.rules, put
To: \.mov$ \.mp3$

Note that the text to the right of "" is a space-separated list
of regular expressions. You need to put the "\" before the "." as
otherwise "." would just match any character, not just the actual "full
stop" character. "$" matches the "end of line", ensuring that the ".mov"
appears at the end of the filename.

3) Run the command "service MailScanner restart" to enable all of this.

That's it!

- ------------------------

Note for advanced users:
The order of checking all of these settings is
Allow Filenames
Deny Filenames
The first rule that matches is the result used.

- ------------------------

> You need to create a rule sets that uses different filename/filetype
> configuration files for mail from different domains for attachment 
> filename
> and filetype checking. If you have a Red Hat, CentOS or SuSE system, the
> following paths will be correct. They will vary on other systems but the
> same principals will work.
> First create two files:
> /etc/MailScanner/
> /etc/MailScanner/
> Copy these existing files to create the new files:
> cp /etc/MailScanner/filename.rules.conf \
>         /etc/MailScanner/
> cp /etc/MailScanner/filenatype.rules.conf \
>         /etc/MailScanner/
> Then edit both the new files to allow or deny the files for xyz.domain
> Then create the file /etc/MailScanner/rules/filename.rules. The contents 
> of
> this file should be:
> # Allow certain filenames from
> From:    /\*@xyz\.com/      /etc/MailScanner/
> # Default entry
> FromOrTo:       default         /etc/MailScanner/filename.rules.conf
> Then create the file /etc/MailScanner/rules/filetype.rules. The contents 
> of
> this file should be:
> # Allow certain filetypes from
> From:    /\*@xyz\.com/      /etc/MailScanner/
> # Default entry
> FromOrTo:       default         /etc/MailScanner/filename.rules.conf
> Then edit /etc/MailScanner.conf to call the new rulesets. Change the 
> setting
> for Filename Rules to be:
> Filename Rules = %rules-dir%/filename.rules
> And change the setting for Filetype Rules to be:
> Filetype Rules = %rules-dir%/filetype.rules
> Then reload MailScanner.
> I hope this helps,
> Steve
> Stephen Swaney
> Fort Systems Ltd.
> stephen.swaney at

- -- 
Julian Field
Buy the MailScanner book at

MailScanner customisation, or any advanced system administration help?
Contact me at Jules at

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
Get your PCs and servers from, very well built and reliable!

Version: PGP SDK 3.7.0
Charset: ISO-8859-1


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

MailScanner mailing list
mailscanner at

Before posting, read

Support MailScanner development - buy the book off the website!

More information about the MailScanner mailing list