O header_checks
não aconteceu porque receive_override_options=no_header_body_checks
está definido em main.cf
, o que desativa as verificações de cabeçalho e corpo.
Estou tentando usar o header_checks do Postfix para o e-mail de entrada [redirect / prepend / reject / anything] com uma pontuação de > = 5 no spamassassin.
Eu posso executar postmap -q - regexp:/etc/postfix/header_checks
em mensagens de e-mail e ele pega o que eu esperaria (mensagens com nível de spam > 5); no entanto, nada está acontecendo com o e-mail recebido.
Isso é /etc/postfix/header_checks
/X-Spam-Level:\s*\*{5,}/ REDIRECT [email protected]
Aqui está a saída do 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
Dentro dos registros, vejo a mensagem passando pelo postfix e, em seguida, uma linha semelhante a esta:
relay=spamassassin, delay=0.76, delays=0.25/0.01/0/0.5, dsn=2.0.0, status=sent (delivered via spamassassin service)
Aqui está a saída completa dos logs em torno de uma das mensagens em questão:
/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
A princípio, pensei que isso indicava que o spamassassin estava entre o Postfix e o Dovecot; no entanto, parece que o Postfix recebe a mensagem de volta de Spamassassin e depois a envia. Nós acabamos testando isso com um cabeçalho relacionado a não-spamassassin (Return-Path) para ver se isso funcionava, mas ainda assim nada acontece. Isso me leva a acreditar que estou perdendo uma opção de configuração que permite verificações de cabeçalho, além de simplesmente incluir header_checks = regexp:/etc/postfix/header_checks
in main.cf
.
Aqui está a saída do postconf -M (o arquivo 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}
O header_checks
não aconteceu porque receive_override_options=no_header_body_checks
está definido em main.cf
, o que desativa as verificações de cabeçalho e corpo.