postfix only allow PDF attachments

Started by umtu06, September 24, 2024, 11:48:34 AM

Previous topic - Next topic

umtu06

Hello. I made the following settings but why is it blocking all attachments?
Why does it block all files including PDF?

main.cfg file content :
header_checks = pcre:/etc/postfix/header_checks

header_checks file content :

#(this working)
/^Subject:.*expires.*$/i DISCARD   


# only allow .pdf but blocking all attachments?  pdf file also blocked.
/^Content-Disposition:.*filename=.*\.pdf$/ OK
/^Content-Disposition:.*filename=.*$/ REJECT

Thanks in advance.

overseer

header_checks = regexp:/etc/postfix/header_checks
/name=[^>]*\.(exe|pif|com|dll|vbs|bat)/   REJECT
/name=[^>]*\.zip/ REJECT no ransomware for us, thanks anyway
/name=[^>]*\.pdf/ PASS PDFs are okay with us

umtu06

Thanks for the answer. Instead of specifying the prohibited file extensions one by one, I would like to block all files except PDF.  8) Is it possible?

cyberspace

Try the following regular expression:

/name=[^>]*\.\w{3}(?<!pdf)/ REJECT attachments not allowed

or

/^Content-Disposition:.*filename=.*\.\w{3}(?<!pdf)/ REJECT attachments not allowed

However, you need to check the above rules very closely.