Dovecot Sieve 无法运行?

Dovecot Sieve 无法运行?

我对 Dovecot 还很陌生,但到目前为止,它对我来说效果很好。我使用 dovecot 和 postfix、amavis 和 spamassassin,一切正常,邮件被标记为垃圾邮件,发送、接收,一切正常。

现在我想添加筛选插件,这样邮件就可以在服务器上移动,但这样做不行。我想先用一个通用脚本将垃圾邮件移到垃圾邮件文件夹,但这样做不行。

所以我搜索了网络并找到了故障排除,上面说 sieve 可能没有运行。我没有找到 sieve 的任何日志条目,所以这可能是问题所在。在这里我发现你必须将 sieve 放入协议中,我猜是在 dovecot.conf 中。

我试过了,dovecot 无法启动,并发布未知协议:sieve。我将 lmtp 添加到协议中,因为我想使用它,它已发布在另一个线程中,但我收到错误:service(lmtp) accces failed: no such file or directory。

一些系统信息:
操作系统:Debian 7
Dovecot 版本:2.1.7

配置文件:dovecot.conf(已减少或添加)

protocols = imap pop3

plugin {
    sieve_before = /var/vmail/sieve/spam-global.sieve
    sieve_dir = /var/vmail/%d/%n/sieve/scripts/
    sieve = /var/vmail/%d/%n/sieve/active-script.sieve
}

conf.d/20-lmtp.conf(已创建)

protocol lmtp {  
    # Space separated list of plugins to load (default is global mail_plugins).  
    mail_plugins = $mail_plugins sieve  
}  

垃圾邮件-global.sieve

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

我如何检查筛子是否正在运行?

据我所知,Postfix 需要配置才能与 sieve 配合使用。我不确定我是否已经这样做了,但只要 sieve 不运行,那就无法解决问题,对吗?

谢谢您的帮助 无效

答案1

您说您必须创建该文件?

听起来你从未安装过 dovecot 下的协议插件。

  1. 首先,如果可以避免,请不要编辑(或创建)已安装的conf文件。自己制作。创建一个/etc/dovecot/local.cfOR /etc/dovecot/conf.d/99-custom.conf(例如)。

  2. 15-lda.conf在较新的 Dovecot 发行版中,默认安装LDA ( ) 插件,但不安装 LMTP 插件 ( 20-lmtp.conf)。您可以使用 LDA 插件。(本地传送代理)。

  3. 如果您仍希望使用 LMTP,则需要安装插件:sudo apt install dovecot-lmtpd。如果您已完成此操作,则无需.conf为其创建文件。

我的相关筛检区域/etc/dovecot/local.cf

protocol imap {

  mail_plugins = autocreate
}
plugin {
   autocreate = Spam
   autosubscribe = Spam
}

# SIEVE STUFF
# Include already included protocols and sieve:
protocols = $protocols sieve

# Allow sieve to be run out of LDA plugin/protocol:
protocol lda {
  mail_plugins = $mail_plugins sieve
}

# Sieve plugin settings
plugin {
   sieve = file:~/sieve;active=~/.dovecot.sieve
   sieve_default = /usr/local/lib/dovecot/sieve/default.sieve
   sieve_global = /usr/local/lib/dovecot/sieve/
}

# May not need this, but it doesn't hurt:
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
}

我的相关筛选区域/etc/postfix/main.cf(使用 dovecot lda/deliver):

mailbox_command = /usr/lib/dovecot/dovecot-lda -f "$SENDER" -a "$RECIPIENT"
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1

我的default.sieve

require ["envelope", "fileinto", "mailbox", "subaddress"];

if header :contains "X-Spam-Flag" "YES" {
        fileinto :create "Spam";
}
if header :contains "X-Amavis-Alert" "BAD HEADER SECTION" {
        fileinto :create "Spam";
}
if address :domain "From" "mydomain.net" {
   if not envelope :domain "From" "mydomain.net" {
      fileinto "Spam";
      stop;
   }
}
if address :domain "From" "mydomain.com" {
   if not envelope :domain "From" "mydomain.com" {
      fileinto "Spam";
      stop;
   }
}

相关领域/etc/amavis/conf.d/50-user(或自行制定99-custom:):

@local_domains_acl  = ( [ ".$mydomain", '.mydomain.net', '.mydomain.com' ] );
@local_domains_maps = ( [ ".$mydomain", '.mydomain.net', '.mydomain.com' ] );
# Do not quarantine or trash emails - hand off to LDA instead
$final_spam_destiny=D_PASS;
$final_virus_destiny=D_PASS;
$final_bad_header_destiny=D_PASS;
@addr_extension_spam_maps=('Spam');

重启Dovecot并测试端口:

# sudo systemctl restart dovecot
# telnet 10.10.10.100 4190
Trying 10.10.10.100...
Connected to 10.10.10.100.
Escape character is '^]'.
"IMPLEMENTATION" "Dovecot (Ubuntu) Pigeonhole"
"SIEVE" "fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext"
"NOTIFY" "mailto"
"SASL" "PLAIN"
"STARTTLS"
"VERSION" "1.0"
OK "Dovecot (Ubuntu) ready."

Dovecot 调试输出-可以看到它的运行情况:

2019-05-16 15:29:49 lda(emailuser1): Debug: Loading modules from directory: /usr/lib/dovecot/modules
2019-05-16 15:29:49 lda(emailuser1): Debug: Module loaded: /usr/lib/dovecot/modules/lib90_sieve_plugin.so
2019-05-16 15:29:49 lda(emailuser1): Debug: Effective uid=1000, gid=1000, home=/home/emailuser1
2019-05-16 15:29:49 lda(emailuser1): Debug: Namespace inbox: type=private, prefix=, sep=, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/home/emailuser1/Maildir
2019-05-16 15:29:49 lda(emailuser1): Debug: maildir++: root=/home/emailuser1/Maildir, index=, indexpvt=, control=, inbox=/home/emailuser1/Maildir, alt=
2019-05-16 15:29:49 lda(emailuser1): Debug: userdb lookup skipped, username taken from USER environment
2019-05-16 15:29:49 lda(emailuser1): Debug: none: root=, index=, indexpvt=, control=, inbox=, alt=
2019-05-16 15:29:49 lda(emailuser1): Debug: Destination address: [email protected] (source: -a parameter)
2019-05-16 15:29:49 lda(emailuser1): Debug: sieve: Pigeonhole version 0.4.21 (92477967) initializing
2019-05-16 15:29:49 lda(emailuser1): Debug: sieve: file storage: Storage path `/home/emailuser1/sieve' not found
2019-05-16 15:29:49 lda(emailuser1): Debug: sieve: file storage: Storage path `/home/emailuser1/.dovecot.sieve' not found
2019-05-16 15:29:49 lda(emailuser1): Debug: sieve: storage: Trying default script location `/usr/local/lib/dovecot/sieve/default.sieve'
2019-05-16 15:29:49 lda(emailuser1): Debug: sieve: file storage: Using Sieve script path: /usr/local/lib/dovecot/sieve/default.sieve
2019-05-16 15:29:49 lda(emailuser1): Debug: sieve: file script: Opened script `default' from `/usr/local/lib/dovecot/sieve/default.sieve'
2019-05-16 15:29:49 lda(emailuser1): Debug: sieve: Using the following location for user's Sieve script: /usr/local/lib/dovecot/sieve/default.sieve

Sieve 现已运行。您的问题已得到解答。

至于我可能遗漏的内容 - 每个设置可能有所不同。如果您仍然遇到问题,请查看一些文章。我的筛选全局规则将隔离内容存储在每个用户的“垃圾邮件”文件夹中(用户是非虚拟的)。正如指出的那样,您可能需要编辑您的 postfix main.cf(如果是虚拟用户/vmail,则编辑 master.cf)正如这里所述使用 Dovecot LDA。您可能还需要编辑内容过滤器(例如 amavis-new),如前所述。那里的文章为了这。

相关内容