1

I am setting up a spam filter on my email server but cannot get sieve to sort the mails. All spams are delivered straight to the inbox despite rules written in .dovecot.sieve. In mail logs Postfix reports that spams (marked with X-Spam-Flag in their headers) are successfully delivered to maildir, and Dovecot reports no error at all. Dovecot version is 2.3.13 (89f716dc2). Please advise.

/etc/postfix/main.cf:

mailbox_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = domain
virtual_mailbox_base = /home/vmail

/etc/dovecot/dovecot.conf:

protocols = imap lmtp

/etc/dovecot/conf.d/10-master.conf:

service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    mode = 0666
  }
}

/etc/dovecot/conf.d/10-mail.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-sieve.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 Answer 1

1

Solved the problem myself.

First of all when using Postfix paired with Dovecot one must explicitly tell it to use Dovecot as the deliver agent for virtual mailboxes. Postfix should send the mail to Dovecot instead of delivering it on its own like previously shown in the logs. Restart Postfix after adding this in /etc/postfix/main.cf:

virtual_transport = lmtp:unix:private/dovecot-lmtp

Next the "~" in /etc/dovecot/conf.d/90-sieve.conf means mail_location instead of mail_home. Setting sieve = ~/.dovecot.sieve caused Dovecot to give these outputs in the debug log:

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.

So I moved .dovecot.sieve to mail_location, and things started to work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .