Mailscanner : Allow extensions like .docx, .dox
Introduction
MailScanner is one of the most widely used email security gateways for Linux mail servers. It scans incoming and outgoing emails for viruses, spam, phishing attempts, and potentially dangerous attachments.
By default, MailScanner may block certain file extensions based on its security policies. In some environments, organizations need to allow additional document formats such as .docx or custom extensions like .dox for business communication.
This guide explains how to configure MailScanner to allow these file extensions safely.
Why MailScanner Blocks Attachments
MailScanner uses filename rules to determine whether an attachment should be:
- Allowed
- Denied
- Renamed
- Quarantined
Blocking potentially dangerous file types helps prevent:
- Malware infections
- Ransomware
- Macro viruses
- Executable attachments disguised as documents
Sometimes legitimate document types must be permitted for internal users.
Step 1: Locate the File Type Rules
MailScanner stores filename rules under:
/etc/MailScanner/
Depending on your distribution, the file may be:
filename.rules.conf
or
filename.rules
Find the active configuration:
grep -i "Filename Rules" /etc/MailScanner/MailScanner.conf
Example output:
Filename Rules = %etc-dir%/filename.rules.conf
Step 2: Open the Rules File
sudo vi /etc/MailScanner/filename.rules.conf
or
sudo nano /etc/MailScanner/filename.rules.conf
Step 3: Check Existing Rules
You may see entries like:
deny \.exe$ deny \.bat$ deny \.scr$ allow \.pdf$ allow \.doc$ allow \.xls$
Step 4: Allow DOCX Files
If .docx is blocked or missing, add:
allow \.docx$
Example:
allow \.doc$ allow \.docx$ allow \.xlsx$ allow \.pptx$
Step 5: Allow Custom DOX Files
If your organization uses a custom extension such as .dox, add:
allow \.dox$
Example:
allow \.doc$ allow \.docx$ allow \.dox$
Example Configuration
# Microsoft Office allow \.doc$ allow \.docx$ allow \.xls$ allow \.xlsx$ allow \.ppt$ allow \.pptx$ # Custom Documents allow \.dox$ # PDF allow \.pdf$
Step 6: Save the File
After making the changes:
:wq
or simply save if using Nano.
Step 7: Restart MailScanner
Reload the service:
sudo systemctl restart MailScanner
Verify the service status:
sudo systemctl status MailScanner
Expected output:
Active: active (running)
Step 8: Test the Configuration
Send a test email with:
- test.docx
- sample.dox
Verify that:
- Email is delivered
- Attachment is not renamed
- Attachment is not quarantined
- No MailScanner warnings appear
Check MailScanner Logs
Monitor logs while testing:
tail -f /var/log/maillog
or
tail -f /var/log/mail.log
You should see entries indicating the message was processed successfully.
If Attachments Are Still Blocked
Check whether another MailScanner rule is overriding your configuration.
Search for .docx:
grep -R "docx" /etc/MailScanner/
Search for .dox:
grep -R "dox" /etc/MailScanner/
Also review:
Filetype Rules Dangerous Content Scanning Archive Rules Incoming Work Directory
Verify MailScanner Configuration
Run:
MailScanner --lint
A successful configuration returns:
Infected message scanner: OK SpamAssassin: OK MailScanner.conf: OK
Resolve any reported errors before restarting the service.
Conclusion
MailScanner provides flexible attachment filtering that helps protect email infrastructure while allowing legitimate business documents. By updating the filename rules to include .docx and custom extensions like .dox, administrators can support organizational workflows without compromising overall email security.
Always validate configuration changes using MailScanner --lint, monitor your mail logs, and allow only trusted file types to maintain a secure and reliable email environment.
