Postfix header_checks 重定向不起作用

Postfix header_checks 重定向不起作用

我正在尝试使用 Postfix header_checks 来 [重定向/添加/拒绝/任何内容] 垃圾邮件分数 >= 5 的传入电子邮件。

我可以运行postmap -q - regexp:/etc/postfix/header_checks电子邮件并且它可以捕获我期望的内容(垃圾邮件级别 > 5 的消息);但是,传入电子邮件没有任何反应。

这是/etc/postfix/header_checks

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

以下是 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

在日志中,我看到消息通过 postfix,然后出现类似如下的一行:

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

以下是有关其中一条消息的日志的完整输出:

/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

起初我以为这表明 spamassassin 介于 Postfix 和 Dovecot 之间;然而,Postfix 似乎从 Spamassassin 接收了消息,然后将其发送出去。我们最终使用与非 spamassassin 相关的标头 (Return-Path) 对此进行了测试,以查看是否有效,但仍然没有任何反应。这让我相信我缺少一个启用标头检查的配置选项,而不仅仅是包含header_checks = regexp:/etc/postfix/header_checks在 中main.cf

以下是 postconf -M 的输出(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} 

答案1

header_checks并没有发生,因为receive_override_options=no_header_body_checks设置了main.cf将禁用标题和正文检查。

Postfix 文档

相关内容