我正在电子邮件服务器上设置垃圾邮件过滤器,但无法使用 sieve 对邮件进行分类。尽管 中规定了规则,但所有垃圾邮件都直接发送到收件箱.dovecot.sieve
。在邮件日志中,Postfix 报告垃圾邮件(X-Spam-Flag
标头中标有 )已成功发送到 maildir,而 Dovecot 报告没有任何错误。Dovecot 版本为 2.3.13 (89f716dc2)。请指教。
在 /etc/postfix/主配置文件:
mailbox_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = domain
virtual_mailbox_base = /home/vmail
/etc/dovecot/dovecot配置文件:
protocols = imap lmtp
/etc/dovecot/conf.d/10-主服务器.conf:
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
mode = 0666
}
}
/etc/dovecot/conf.d/10-邮件.conf:
mail_home = /home/vmail/%d/%n/home
mail_location = maildir:/home/vmail/%d/%n
/etc/dovecot/conf.d/20-lmtp.conf:
protocol lmtp {
mail_plugins = $mail_plugins sieve
}
/etc/dovecot/conf.d/90-筛.conf:
sieve = ~/.dovecot.sieve
/home/vmail/domain.com/user1/home/.dovecot.sieve:
require ["fileinto"];
if header :contains "X-Spam-Flag" "YES" {
fileinto "Junk";
stop;
}
答案1
我自己解决了这个问题。
首先,当使用 Postfix 与 Dovecot 配对时,必须明确告诉它使用 Dovecot 作为以下传递代理:虚拟的邮箱。Postfix 应该将邮件发送到 Dovecot,而不是像之前日志中显示的那样自行发送。在 /etc/postfix/ 中添加此内容后,重新启动 Postfix主配置文件:
virtual_transport = lmtp:unix:private/dovecot-lmtp
接下来是 /etc/dovecot/conf.d/ 中的“~”90-筛.conf表示 mail_location 而不是 mail_home。设置sieve = ~/.dovecot.sieve
导致 Dovecot 在调试日志中给出以下输出:
Debug: sieve: include: sieve_global is not set; it is currently not possible to include `:global' scripts.
Debug: sieve: file storage: Storage path `/home/vmail/domain/user1/.dovecot.sieve' not found
Debug: sieve: storage: No default script location configured
Debug: sieve: User has no personal script
Debug: sieve: No scripts to execute: reverting to default delivery.
所以我搬家了.dovecot.sieve到 mail_location,一切就开始正常工作了。