Postfix block PDF or ZIP files attachments

by on August 10, 2007 · 4 comments· LAST UPDATED August 10, 2007

in , ,

Q. How do I block all PDF or ZIP files attachments under Postfix Mail Server?

A. You can easily block email attachments using mime header check.

Open postfix config file

Login as the root, enter:
# vi /etc/postfix/main.cf

Block zip or pdf files

Use mime_header_checks postfix config directive, enter:
mime_header_checks = regexp:/etc/ostfix/block_attachments
Save and close the file. Open /etc/ostfix/block_attachments file and append code as follows:
/name=[^>]*\.(pdf|zip)/ REJECT
Save and close the file.

Restart Postfix MTA

You must restart or reload postfix:
# /etc/init.d/postfix reload

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 Mustafa September 20, 2011 at 2:08 pm

Hi,
This will block attachments for all the accounts on the server, what I want to do is block all outgoing attachments for one account.
Is there is a way to do that ?

Reply

2 Itelica April 26, 2013 at 8:19 am

This worked for us, thanks. Just one thing, you have missed out the P in postfix in the regexp line entry. We noticed it and changed it but others may not.

Reply

3 Ramesh July 23, 2014 at 5:08 pm

Hi,

Please advice me how to block zip file include exe in postfix.

Thanks for advance
Ramesh

Reply

4 dxman August 15, 2014 at 12:32 pm

hi admin,
i am not getting bounce back email if the user tried to send email with the ( exceeded quota )attachment. mail deliver to recipient but the attachment is drop by server (if attach using the outlook)

Reply

Leave a Comment

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: