Dovecot Sieve 不会将垃圾邮件移至 maildir 中的垃圾邮件文件夹

Dovecot Sieve 不会将垃圾邮件移至 maildir 中的垃圾邮件文件夹

我有一台 Ubuntu 16.04 邮件服务器postfix/spamassassin/dovecot使用虚拟邮箱邮件目录格式。一年来,整个过程运行良好。垃圾邮件被标记为主题中包含“*****SPAM*****”,并且电子邮件标题中包含“X-Spam-Flag: YES”。

我现在尝试添加到 dovecot 移动垃圾邮件到垃圾邮件文件夹没有成功,我没有看到任何迹象表明做某事。

我的dovecot.conf:

auth_mechanisms = cram-md5
auth_verbose = yes
base_dir = /var/run/dovecot/
info_log_path = /var/log/dovecot.info
log_path = /var/log/dovecot
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n
passdb {
  args = /etc/dovecot/passwd
  driver = passwd-file
}
protocols = imap pop3
service auth {
  executable = /usr/lib/dovecot/auth
  user = root
}
service imap-login {
  chroot = login
  executable = /usr/lib/dovecot/imap-login
  user = dovecot
  # disable non secure IMAP
  inet_listener imap {
    port = 0
  }
}
service imap {
  executable = /usr/lib/dovecot/imap
}
service pop3-login {
  chroot = login
  executable = /usr/lib/dovecot/pop3-login
  user = dovecot
  # disable pop3
  inet_listener pop3 {
    port = 0
  }
  inet_listener pop3s {
    port = 0
  }
}
service pop3 {
  executable = /usr/lib/dovecot/pop3
}
ssl = no
userdb {
  args = /etc/dovecot/users
  driver = passwd-file
}
valid_chroot_dirs = /var/spool/vmail
protocol pop3 {
  pop3_uidl_format = %08Xu%08Xv
}

# SSL settings
ssl = yes
ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.pem

# SMTP authentication
service auth {
  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
}

# Default separator definition needed by doveadm for migration
namespace {
  inbox = yes
  separator = /
}

plugin {
  sieve = /etc/dovecot/sieve/default.sieve
}
protocol lda {
  mail_plugins = $mail_plugins sieve
}

我只添加了插入协议lda现在。文件的内容默认筛分

require "fileinto";
if header :contains "X-Spam-Flag" "YES" {
    fileinto "Junk";
}

测试垃圾邮件被标记为垃圾邮件,但未移至垃圾邮件文件夹。我没有看到任何内容邮件日志与筛子相关的是:

Jul 30 20:05:12 zg-3 postfix/smtpd[4446]: connect from smtp4.enternet.hu[62.112.192.37] 
Jul 30 20:05:13 zg-3 postfix/smtpd[4446]: 3C4CC9F570: client=smtp4.enternet.hu[62.112.192.37] 
Jul 30 20:05:13 zg-3 postfix/cleanup[4450]: 3C4CC9F570: message-id=<[email protected]> 
Jul 30 20:05:13 zg-3 postfix/qmgr[1557]: 3C4CC9F570: from=<[email protected]>, size=918, nrcpt=1 (queue active) 
Jul 30 20:05:13 zg-3 postfix/smtpd[4446]: disconnect from smtp4.enternet.hu[62.112.192.37] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7 
Jul 30 20:05:13 zg-3 postfix/pickup[3949]: 5F7FEA3CBC: uid=1003 from=<[email protected]> 
Jul 30 20:05:13 zg-3 postfix/pipe[4451]: 3C4CC9F570: to=<[email protected]>, relay=spamassassin, delay=0.15, delays=0.05/0.01/0/0.1, dsn=2.0.0, status=sent (delivered via spamassassin service) 
Jul 30 20:05:13 zg-3 postfix/qmgr[1557]: 3C4CC9F570: removed 
Jul 30 20:05:13 zg-3 postfix/cleanup[4450]: 5F7FEA3CBC: message-id=<[email protected]> 
Jul 30 20:05:13 zg-3 postfix/qmgr[1557]: 5F7FEA3CBC: from=<[email protected]>, size=3304, nrcpt=1 (queue active) 
Jul 30 20:05:13 zg-3 postfix/virtual[4455]: 5F7FEA3CBC: to=<[email protected]>, relay=virtual, delay=0.02, delays=0.01/0.01/0/0, dsn=2.0.0, status=sent (delivered to maildir) 
Jul 30 20:05:13 zg-3 postfix/qmgr[1557]: 5F7FEA3CBC: removed 

什么可能出错?

答案1

问题是,Postfix 没有配置为通过 dovecot 的 LDA 进行传送,因此 sieve 从未被调用。

postfix/master.cf 中的相应配置行

smtp      inet  n       -       -       -       -       smtpd
  -o content_filter=spamassassin
[...]
### Configuration for dovecot as LDA (New 2019-08-13)
# spamassassin unix -     n       n       -       -       pipe
#  user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${original_recipient}
spamassassin unix -     n       n       -       -       pipe
  flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e
  /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}
dovecot unix -     n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}

postfix/main.cf 中的相应配置行:

### Configuration for dovecot as LDA (New 2019-08-13)
virtual_transport = dovecot
spamassassin_destination_recipient_limit = 1
dovecot_destination_recipient_limit = 1

文件dovecot配置文件筛/默认.筛与问题中的相同。

值得检查/var/log/dovecot.info/var/log/mail.log垃圾邮件中应该出现类似的内容:

2019-08-13 15:52:15 lda([email protected]): Info: sieve: msgid=<[email protected]>: stored mail into mailbox 'Junk'

相关内容