web-dev-qa-db-fra.com

Header_checks de Postfix pour la redirection ne fonctionne pas

J'essaie d'utiliser Postfix header_checks pour [réorienter/pré-insérer/rejeter/quoi que ce soit] les e-mails entrants avec un score de spamassassin de> = 5.

Je peux exécuter postmap -q - regexp:/etc/postfix/header_checks sur des messages électroniques et il répond à ce que j'attendais (messages avec un niveau de spam supérieur à 5); Cependant, rien ne se passe pour le courrier entrant.

C'est /etc/postfix/header_checks

/X-Spam-Level:\s*\*{5,}/ REDIRECT [email protected]

Voici le résultat de postconf -n:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
header_checks = regexp:/etc/postfix/header_checks
inet_interfaces = all
mailbox_size_limit = 0
milter_default_action = accept
milter_protocol = 2
mydestination = localhost
myhostname = emaproduction.mydomain.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
non_smtpd_milters = inet:localhost:8891
readme_directory = no
recipient_delimiter = +
relayhost =
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_milters = inet:localhost:8891
smtpd_relay_restrictions = permit_sasl_authenticated permit_mynetworks               reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/certs/dovecot.pem
smtpd_tls_key_file = /etc/ssl/private/dovecot.pem
smtpd_use_tls = yes
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp

Dans les journaux, je vois le message passer par postfix, puis une ligne semblable à celle-ci:

relay=spamassassin, delay=0.76, delays=0.25/0.01/0/0.5, dsn=2.0.0, status=sent (delivered via spamassassin service)

Voici la sortie complète des journaux entourant l'un des messages en question:

/var/log/mail.log 
May  6 09:27:40 emaproduction postfix/smtpd[10044]: connect from mail-wi0-f182.google.com[209.85.212.182] 
May  6 09:27:41 emaproduction postfix/smtpd[10044]: 5796F2E2AF: client=mail-wi0-f182.google.com[209.85.212.182] 
May  6 09:27:41 emaproduction postfix/cleanup[10085]: 5796F2E2AF: message-id=<CAKiO3cJu_5vF7-J_---edited-out----oi3iuSPQ_NSobSkj0Q@mail.gmail.com> 
May  6 09:27:41 emaproduction opendkim[19408]: 5796F2E2AF: mail-wi0-f182.google.com [209.85.212.182] not internal 
May  6 09:27:41 emaproduction opendkim[19408]: 5796F2E2AF: not authenticated 
May  6 09:27:41 emaproduction opendkim[19408]: 5796F2E2AF: no signature data 
May  6 09:27:41 emaproduction postfix/qmgr[9847]: 5796F2E2AF: from=<[email protected]>, size=2016, nrcpt=1 (queue active) 
May  6 09:27:41 emaproduction postfix/smtpd[10044]: disconnect from mail-wi0-f182.google.com[209.85.212.182] 
May  6 09:27:43 emaproduction postfix/pickup[9846]: 0ABDF2E895: uid=5001 from=<[email protected]> 
May  6 09:27:43 emaproduction postfix/pipe[10023]: 5796F2E2AF: to=<[email protected]>, relay=spamassassin, delay=1.8, delays=0.24/0/0/1.5, dsn=2.0.0, status=sent (delivered via spamassassin service) 
May  6 09:27:43 emaproduction postfix/qmgr[9847]: 5796F2E2AF: removed 
May  6 09:27:43 emaproduction postfix/cleanup[10047]: 0ABDF2E895: message-id=<CAKiO3cJu_5vF7-J_---edited-out-----oi3iuSPQ_NSobSkj0Q@mail.gmail.com> 
May  6 09:27:43 emaproduction opendkim[19408]: 0ABDF2E895: no signing table match for '[email protected]' 
May  6 09:27:43 emaproduction opendkim[19408]: 0ABDF2E895: no signature data 
May  6 09:27:43 emaproduction postfix/qmgr[9847]: 0ABDF2E895: from=<[email protected]>, size=2429, nrcpt=1 (queue active) 
May  6 09:27:43 emaproduction postfix/lmtp[10028]: 0ABDF2E895: to=<[email protected]>, relay=emaproduction.mydomain.com[private/dovecot-lmtp], delay=0.03, delays=0.01/0/0/0.01, dsn=2.0.0, status=sent (250 2.0.0 <[email protected]> yEEyA0/jaFO2JwAAL7A4mg Saved) 
May  6 09:27:43 emaproduction postfix/qmgr[9847]: 0ABDF2E895: removed

Au début, je pensais que le spamassassin indiqué se trouvait entre Postfix et Dovecot; Cependant, il semble que Postfix reçoive le message de Spamassassin, puis l'envoie. Nous avons fini par tester cela avec un en-tête (Return-Path) non lié à spamassassin pour voir si cela fonctionnait, mais rien ne se passe toujours. Cela me porte à croire qu'il me manque une option de configuration permettant les vérifications d'en-tête, au-delà de la simple inclusion de header_checks = regexp:/etc/postfix/header_checks dans main.cf.

Voici la sortie de postconf -M (le fichier master.cf])

smtp       inet  n       -       -       -       -       smtpd -o content_filter=spamassassin 
submission inet  n       -       -       -       -       smtpd -o smtpd_sasl_auth_enable=yes -o smtpd_relay_restrictions=permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtps      inet  n       -       n       -       -       smtpd -o smtpd_sasl_auth_enable=yes -o smtpd_relay_restrictions=permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination 
pickup     unix  n       -       -       60      1       pickup 
pickup     fifo  n       -       -       60      1       pickup -o content_filter= -o receive_override_options=no_header_body_checks 
cleanup    unix  n       -       -       -       0       cleanup 
qmgr       unix  n       -       n       300     1       qmgr 
tlsmgr     unix  -       -       -       1000?   1       tlsmgr 
rewrite    unix  -       -       -       -       -       trivial-rewrite 
bounce     unix  -       -       -       -       0       bounce 
defer      unix  -       -       -       -       0       bounce 
trace      unix  -       -       -       -       0       bounce 
verify     unix  -       -       -       -       1       verify 
flush      unix  n       -       -       1000?   0       flush 
proxymap   unix  -       -       n       -       -       proxymap 
proxywrite unix  -       -       n       -       1       proxymap 
smtp       unix  -       -       -       -       -       smtp 
relay      unix  -       -       -       -       -       smtp 
showq      unix  n       -       -       -       -       showq 
error      unix  -       -       -       -       -       error 
retry      unix  -       -       -       -       -       error 
discard    unix  -       -       -       -       -       discard 
local      unix  -       n       n       -       -       local 
virtual    unix  -       n       n       -       -       virtual 
lmtp       unix  -       -       -       -       -       lmtp 
anvil      unix  -       -       -       -       1       anvil 
scache     unix  -       -       -       -       1       scache 
maildrop   unix  -       n       n       -       -       pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} 
uucp       unix  -       n       n       -       -       pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) 
ifmail     unix  -       n       n       -       -       pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) 
bsmtp      unix  -       n       n       -       -       pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient 
scalemail-backend unix - n       n       -       2       pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension} 
mailman    unix  -       n       n       -       -       pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user} 
smtp-amavis unix -       -       -       -       2       smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes -o max_use=20 
127.0.0.1:10025 inet n   -       -       -       -       smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_delay_reject=no -o smtpd_client_restrictions=permit_mynetworks,reject -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o smtpd_data_restrictions=reject_unauth_pipelining -o smtpd_end_of_data_restrictions= -o mynetworks=127.0.0.0/8 -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks 
spamassassin unix -      n       n       -       -       pipe user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient} 
5
Chris Rockwell

Le header_checks n'a pas eu lieu car receive_override_options=no_header_body_checks est défini dans main.cf, ce qui désactive les contrôles d'en-tête et de corps.

Docs Postfix

4
clement