大网数据广告活动
服务器运维问答

Spamassassin, Dovecot and Postfix: Move spam to folder

· 52CE 我爱测

I am trying to move Spam detected by spamassassin automatically to the Junk folder on Debian Jessie. I installed Spamassassin and edited the configs: local.cf (spamassassin folder) rewrite_header Subject *****SPAM***** main.cf sp…

问题原文

原帖链接 · Nidhoegger · CC BY-SA 3.0

I am trying to move Spam detected by spamassassin automatically to the Junk folder on Debian Jessie.

I installed Spamassassin and edited the configs:

local.cf (spamassassin folder)

rewrite_header Subject *****SPAM*****

main.cf

spamassassin_destination_recipient_limit = 1

master.cf

smtp      inet  n       -       -       -       -       smtpd
        -o content_filter=spamassassin

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}

90-plugins.conf (dovecot)

plugin {
  #setting_name = value
  sieve = /etc/dovecot/sieve/default.sieve
}

default.sieve

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

15-mailboxes.conf (postfix)

mailbox Junk {
   auto = subscribe
   special_use = \Junk
}

The Spam gets marked as *****SPAM***** correctly, but is not moved into the Junk folder (i use roundcube as mail client, the Junkfolder does not even show up. There are no errors in the mail.info log either:

Mar 18 17:22:29 *************** postfix/smtpd[6184]: connect from mail-io0-f173.google.com[209.85.223.173]
Mar 18 17:22:29 *************** postfix/smtpd[6184]: DD759241A7B: client=mail-io0-f173.google.com[209.85.223.173]
Mar 18 17:22:30 *************** postfix/cleanup[6189]: DD759241A7B: message-id=<[email omitted]>
Mar 18 17:22:30 *************** postfix/qmgr[4489]: DD759241A7B: from=<***************m>, size=2492, nrcpt=1 (queue active)
Mar 18 17:22:30 *************** spamd[4506]: spamd: connection from ip6-localhost [::1]:46206 to port 783, fd 6
Mar 18 17:22:30 *************** spamd[4506]: spamd: processing message <[email omitted]> for vmail:5555
Mar 18 17:22:30 *************** postfix/smtpd[6184]: disconnect from mail-io0-f173.google.com[209.85.223.173]
Mar 18 17:22:30 *************** spamd[4506]: spamd: identified spam (1000.3/2.0) for vmail:5555 in 0.2 seconds, 2547 bytes.
Mar 18 17:22:30 *************** spamd[4506]: spamd: result: Y 1000 - FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GTUBE,HTML_MESSAGE,RCVD_IN_MSPIKE_H2,SPF_PASS,TVD_SPACE_RATIO,T_DKIM_INVALID scantime=0.2,size=2547,user=vmail,uid=5555,required_score=2.0,rhost=ip6-localhost,raddr=::1,rport=46206,mid=<[email omitted]>,autolearn=no autolearn_force=no
Mar 18 17:22:30 *************** spamd[4505]: prefork: child states: II
Mar 18 17:22:30 *************** dovecot: lda(***************): msgid=<[email omitted]>: saved mail to INBOX
Mar 18 17:22:30 *************** postfix/pipe[6192]: DD759241A7B: to=<***************>, relay=spamassassin, delay=0.63, delays=0.32/0/0/0.3, dsn=2.0.0, status=sent (delivered via spamassassin service)
Mar 18 17:22:30 *************** postfix/qmgr[4489]: DD759241A7B: removed

社区高分解答

原帖链接 · dek.tiram · CC BY-SA 3.0

To manage filter rule you can use sieve on dovecot. You can put it as global sieve or per user sieve.

For global sieve use configuration in /etc/dovecot/dovecot.conf :

sieve_global_path = /home/vmail/sieve/dovecot.sieve

For sieve per user use configuration :

sieve = /%Lh/sieve/dovecot.sieve

which %Lh===dovecot will change it to user mailbox dir

This is example for sieve files content:

if header :contains "*****SPAM*****" "YES"
{
    fileinto "Junk";
    stop;
}

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。