Author Topic: postfix only allow PDF attachments  (Read 297 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
postfix only allow PDF attachments
« on: September 24, 2024, 11:48:34 AM »
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.

Offline
*****
Re: postfix only allow PDF attachments
« Reply #1 on: September 25, 2024, 03:31:45 AM »
header_checks = regexp:/etc/postfix/header_checks
Code: [Select]
/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

Offline
*
Re: postfix only allow PDF attachments
« Reply #2 on: September 25, 2024, 06:28:31 AM »
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?

Offline
***
Re: postfix only allow PDF attachments
« Reply #3 on: September 26, 2024, 01:06:41 PM »
Try the following regular expression:

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

Code: [Select]
/^Content-Disposition:.*filename=.*\.\w{3}(?<!pdf)/ REJECT attachments not allowed
However, you need to check the above rules very closely.