我希望我的家庭 postfix 设置是相当正常的。我使用 fetchmail 获取 POP3 邮件,然后通过 /usr/sbin/sendmail 将其传递给 postfix。在 postfix 的 master.cf 中,我添加了一项spamassassin
服务,并设置了-o content_filter=spamassassin
smtp 服务。
我希望 postfix 使用 spamassassin 来过滤收到的邮件,但是由于某种原因它没有这样做。
它是但是,过滤外发邮件:以下是 /var/log/mail.log 中的一些示例:
接收(未过滤,为什么没有?):
Sep 19 01:40:05 fitpc postfix/local[31480]: 062CC2CE070F: to=<[email protected]>, orig_to=<mailandy>, relay=local, delay=0.43, delays=0.24/0.05/0/0.14, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
发送(已过滤,实际上不需要这个):
Sep 19 01:07:16 fitpc postfix/pipe[31190]: 8CB252CE070E: to=<[email protected]>, relay=spamassassin, delay=0.48, delays=0.1/0.05/0/0.33, dsn=2.0.0, status=sent (delivered via spamassassin service)
是不是因为 fetchmail 使用 /usr/sbin/sendmail 而不是通过网络与 postfix 通信?或者 sendmail 也通过网络通信?
配置:
$ postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
message_size_limit = 0
mydestination = fitpc, localhost.localdomain, localhost, ubuntu-desktop, server-vm, example.com
myhostname = fitpc
mynetworks = 127.0.0.0/8 10.0.1.0/24 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = example.com
notify_classes = resource,software,bounce,2bounce,delay,policy,protocol
readme_directory = no
recipient_delimiter = +
relayhost = relay.plus.net
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_relay_restrictions = permit_sasl_authenticated,defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
$ postconf -M
2025 inet n - - - - smtpd -o content_filter=spamassassin
pickup unix n - - 60 1 pickup
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 -o smtp_fallback_relay=
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}
spamassassin unix - n n - - pipe -v user=debian-spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
答案1
当然,我一写完这篇文章就有一个想法,并且让它发挥作用。
问题根本不是在 postfix 或 spamassassin 配置中,而是在 fetchmail 配置中。
我的 .fetchmailrc 中有这个:
poll example.com with proto POP3
user 'x' there with password 'y' is 'z' here
mda "/usr/sbin/sendmail -i -f %F -- %T"
但是由于使用了/usr/sbin/sendmail
,它不会将邮件放入 postfix 的队列中,而是直接发送(事实证明如此),因此它会绕过垃圾邮件过滤器。我需要的是:
poll example.com with proto POP3
user 'x' there with password 'y' is 'z' here
smtphost localhost/2025
(因为我的 postfix 监听端口 2025。如果它监听端口 25,我们就根本不需要 smpthost 行。)