SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 10
How to block certain attachment types in Postfix
How to block certain attachments based on the extension of the file name
1. Launch a Terminal and become the root user. Backup main.cf file located in /etc/postfix directory and edit it.
su -
cp /etc/postfix/main.cf /etc/postfix/main.cf.original
vi /etc/postfix/main.cf
2. Search for the line
# header_checks = regexp:/etc/postfix/header_checks
3. Remove the # (hash) from the above mentioned line and save the file.
4. Backup header_checks file located in /etc/postfix and edit it
cp /etc/postfix/header_checks /etc/postfix/header_checks.original
vi /etc/postfix/header_checks
5. Add the following line at the bottom of the file and save it
/name=[^>]*\.(exe|pif|com|dll|vbs|bat)/ REJECT
(Add other extensions that need to be blocked)
6. Restart the postfix service
/etc/init.d/postfix restart
To test the configuration, send a test message with an attachment type mentioned in the header_checks file
mail -a /path_to_file user_name
put the subject name
end the message with a . (dot)
check the the log file
tail -f /var/log/mail
It will show an entry somthing like this
"Date Time hostname postfix/cleanup[xxxxx]: xxxxxxxxxx: reject: header Content-Disposition: attachment;? filename="filename.extension" from local; from=< user@domain_name > to to=< user@domain_name >: Message content rejected"
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.