How to make spamassasin reject mail based on score?

Van*_*yen 7 linux postfix configuration spam spamassassin

I am running Linux with Postfix, Dovecot, Postgrey and spamassasin/spamd.

This is my main.cf

smtpd_recipient_restrictions = permit_sasl_authenticated,
                               permit_mynetworks,
                               reject_unauth_destination,
                               reject_invalid_hostname,
                               reject_unauth_pipelining,
                               reject_non_fqdn_sender,
                               reject_unknown_sender_domain,
                               reject_non_fqdn_recipient,
                               reject_unknown_recipient_domain,
                               check_policy_service inet:127.0.0.1:10030
Run Code Online (Sandbox Code Playgroud)

I got spamassasin to add spam header to other emails that postfix didn't catch, but how to make it reject?

小智 8

您可以将 postfix 配置为使用 Spamassasin/Amavis 作为代理过滤器。这样可以防止退回:到 SMTP 远程端的连接将保持打开状态,直到垃圾邮件检查完成并且 postfix 将以 OK 或 REJECTED 消息响应。这样,远程端负责反弹。

# master.cf

# mail inbound
smtp      inet  n       -       -       -       -       smtpd
    -o smtpd_proxy_filter=127.0.0.1:10024
    -o smtpd_client_connection_count_limit=10
    -o smtpd_proxy_options=speed_adjust

# spamassasin/amavis is listening to port 10024 and sending it's
# checked mail to port 10025
amavis    unix  -       -       n       -       2       smtp
   -o smtp_data_done_timeout=1200
   -o smtp_send_xforward_command=yes
   -o disable_dns_lookups=yes

# SMTP return (from amavis/spamassasin)
localhost:10025 inet  n -       n       -      -        smtpd
   -o content_filter=
   -o local_recipient_maps=
   -o relay_recipient_maps=
   -o smtpd_restriction_classes=
   -o smtpd_client_restrictions=
   -o smtpd_helo_restrictions=
   -o smtpd_sender_restrictions=
   -o smtpd_recipient_restrictions=permit_mynetworks,reject
   -o smtpd_override_options=no_address_mappings
   -o mynetworks=127.0.0.0/8
   -o receive_override_options=no_unknown_recipient_checks
Run Code Online (Sandbox Code Playgroud)
# main.cf

# for rejecting spam
header_checks = pcre:/etc/postfix/header_checks
Run Code Online (Sandbox Code Playgroud)
# header_checks

/X-Spam-Level: \*{9,}/ REJECT Looks like spam to me.
Run Code Online (Sandbox Code Playgroud)

如果您使用 Amavis 调用 spamassasin,您可以让 Amavis 为您拒绝邮件——拒绝阈值可以配置为$sa_kill_level_deflt. 使用 Amavis 时添加,no_header_body_checksreceive_override_optionsSMTP 返回条目。