Control Web Panel

WebPanel => Postfix => Topic started by: umtu06 on September 24, 2024, 11:48:34 AM

Title: postfix only allow PDF attachments
Post by: umtu06 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.
Title: Re: postfix only allow PDF attachments
Post by: overseer 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
Title: Re: postfix only allow PDF attachments
Post by: umtu06 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?
Title: Re: postfix only allow PDF attachments
Post by: cyberspace 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.