Skip to content

Postfix - Header Filter

Wir erstellen uns dafür ein Filter header_checks, der das Subject prüft.

Zuerst installieren wir das postfix-pcre Paket.

root:~# apt-get install postfix-pcre

Dann erstellen wir die REGEXP um das entsprechende Subject zu finden.

root:~# vi /etc/postfix/header_checks.pcre
/^Subject:\s+(AW:\s+\w+\s+ID[^#]+#[^#]+#[^#]+#)$/x DISCARD Oops, the subject -$1- is banned!

Nun erstellen wir mit postmap eine header_checks.pcre.db

root:~# cd /etc/postfix/
root:/etc/postfix# postmap header_checks.pcre

Wir tragen den Header Filter in der main.cf ein.

root:/etc/postfix# vi main.cf
header_checks = pcre:/etc/postfix/header_checks.pcre

Die Konfiguration sollte nun neu eingelesen werden.

root:/etc/postfix# postfix reload

Nun erstellen wir eine Testmail und schauen in den Logfiles nach, was mit der Mail passiert.

root:/etc/postfix# echo "Das ist eine Testmail" | mail -s "AW: testmail ID1695324880#26172548#75201a4#" bubu

Auszug auf dem Logfile /var/log/mail.log

root:/etc/postfix# tail /var/log/mail.log
....
Oct 12 11:33:22 dev001 postfix/pickup[8590]: E09288F42C: uid=0 from=<root>
Oct 12 11:33:22 dev001 postfix/cleanup[8596]: E09288F42C: discard: header Subject: AW: testmail ID1695324880#26172548#75201a4# from local; from=<root@earth.example.com> to=<bubu@earth.example.com>: Oops, the subject -AW: testmail ID1695324880#26172548#75201a4#- is banned!