SUSE Support

Here When You Need Us

How to block certain attachment types in Postfix

This document (7000885) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 10

Situation

How to block certain attachment types in Postfix
How to block certain attachments based on the extension of the file name

Resolution

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

Additional Information

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"

Disclaimer

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.

  • Document ID:7000885
  • Creation Date: 03-Mar-2009
  • Modified Date:10-Mar-2021
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.