使用 postfix 调试 spamassassin

使用 postfix 调试 spamassassin

我正在尝试在我的 postfix 邮件服务器上设置 spamassassin milter。

SpamAssassin Server version 3.4.1
  running on Perl 5.20.2
  with SSL support (IO::Socket::SSL 2.019)
  with zlib support (Compress::Zlib 2.064)

Postfix mail_version = 2.11.3

当我通过将其添加到此行来激活过滤器时:

smtpd_milters = unix:/spamassassin/spamd.sock unix:/clamav/clamav-milter.ctl unix:/opendkim/opendkim.sock

奇怪的是,发送邮件需要更长的时间才能完成(我以为 spamassassin 只对收到的电子邮件起作用)并且我收到以下日志:

Jan 28 15:39:38 mymailserver spamd[22388]: spamd: got connection over /var/spool/postfix/spamassassin/spamd.sock
Jan 28 15:40:08 mymailserver spamd[22388]: spamd: timeout: (30 second socket timeout reading input from client)
Jan 28 15:40:08 mymailserver postfix/smtpd[29865]: warning: milter unix:/spamassassin/spamd.sock: unreasonable packet length: 1397768525 > 1073741823
Jan 28 15:40:08 mymailserver postfix/smtpd[29865]: warning: milter unix:/spamassassin/spamd.sock: read error in initial handshake

最后一个错误是随机变化的,有时它会抱怨期待某些东西但收到了其他东西,这听起来很合理,因为它在从套接字读取时遇到了问题。

我想学习如何调试它,但我甚至不知道从哪里开始。至少我确定套接字存在并且拥有正确的所有者,至少从我们got connection over ...可以排除套接字存在和权限来看。

还有一些其他警告,我不确定它们是否相关,但我正在考虑在之后解决这些问题

Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: Pigeonhole version 0.4.8 (0c4ae064f307+) initializing
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: include: sieve_global is not set; it is currently not possible to include `:global' scripts.
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: file storage: Storage path `/var/mail/vmail/mydomain.com/me/sieve' not found
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: file storage: Using Sieve script path: /var/mail/vmail/mydomain.com/me/.dovecot.sieve
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: file storage: Storage path `/var/mail/vmail/mydomain.com/me/.dovecot.sieve' not found
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: storage: No default script location configured
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: User has no personal script
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: file storage: Storage path `/var/mail/vmail/sieve-before' not found
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: Location for sieve_before not found: /var/mail/vmail/sieve-before
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: file storage: Storage path `/var/mail/vmail/sieve-after' not found
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: Location for sieve_after not found: /var/mail/vmail/sieve-after
Jan 28 15:40:09 mymailserver dovecot: lda([email protected]): Debug: sieve: No scripts to execute: reverting to default delivery.

** 更新 1 **

这是我的 main.cf 的内容

alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
default_destination_concurrency_limit = 5
disable_vrfy_command = yes
inet_interfaces = all
inet_protocols = all
local_recipient_maps = unix:passwd.byname $alias_maps
mailbox_size_limit = 0
message_size_limit = 104857600
milter_connect_macros = j {daemon_name} v {if_name} _
milter_default_action = accept
mydestination = localhost.$mydomain, localhost, $mydomain
mydomain = example.com
myhostname = mail.example.com
mynetworks = 127.0.0.0/8 10.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
non_smtpd_milters = $smtpd_milters
readme_directory = no
recipient_delimiter = +
relay_destination_concurrency_limit = 1
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks, reject_invalid_helo_hostname, permit
smtpd_milters = unix:/clamav/clamav-milter.ctl unix:/opendkim/opendkim.sock
smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_invalid_hostname, reject_non_fqdn_sender
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_login_maps = $virtual_mailbox_maps
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_checks, reject_unknown_sender_domain, reject_sender_login_mismatch
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtpd_tls_ask_ccert = yes
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/private/mail_example_com.pem
smtpd_tls_ciphers = high
smtpd_tls_key_file = /etc/ssl/private/mail_example_com.key
smtpd_tls_loglevel = 0
smtpd_tls_mandatory_ciphers = medium
smtpd_tls_mandatory_protocols = SSLv3, TLSv1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_address_reject_code = 550
unknown_client_reject_code = 550
unknown_hostname_reject_code = 550
unknown_local_recipient_reject_code = 550
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_mailbox_base = /var/mail/vmail
virtual_mailbox_domains = hash:/etc/postfix/virtual-mailbox-domains
virtual_mailbox_maps = hash:/etc/postfix/virtual-mailbox-users
virtual_transport = dovecot

答案1

如果我理解正确的话,那么 spamassassin(或者您在此处使用的 spamd)不能直接用作过滤工具。

除了 spamassassin 之外,您还需要 spamass-milter。

看这里: http://www.stefan-seelmann.de/wiki/mailserver-postfix-dovecot 或者这里: https://www.nesono.com/node/220 以供参考。

答案2

正如接受的答案所指出的那样,有几个组件可以使其工作。我已经安装了 spamassassin 和 spamass-milter。

但是,在设置过程中,我误解了如何设置套接字,因此这里是相关的文件/行

第一个 /etc/default/spamassassin :

OPTIONS="-x --max-children 5 --nouser-config --helper-home-dir /var/lib/spamassassin -u debian-spamd -g debian-spamd --siteconfigpath /etc/spamassassin --socketpath=/var/run/spamassassin/spamd.sock --socketowner=debian-spamd --socketgro$

第二个 /etc/default/spamass-milter :

OPTIONS="-u spamass-milter -i 127.0.0.1 -m -I -- --socket=/var/run/spamassassin/spamd.sock"

最后,/etc/postfix/main.cf

smtpd_milters = unix:/spamass/spamass.sock

总而言之,据我所知,使用了几个套接字。一个用于 milter 和 spamassassin 之间的通信(spamd.sock),另一个用于 Postfix 和 milter 之间的通信(spamass.sock)。以前我曾强制它们都使用同一个套接字,这解释了为什么有时它会工作(偶然),有时错误会指出一些意想不到的事情......

因此,正确设置这些后,有关 spamassassin 的错误就消失了,性能也恢复了。我也没有看到任何与 sieve 相关的消息,但我不完全确定它们是否相关。除了上面的配置更改之外,我没有做任何其他配置更改。

相关内容