How are user specific Sieve files created

dovecotemail-serverpostfixsieve

My Dovecot's protocol_lda is as follows:

protocol lda {
    log_path = /var/log/mail/dovecot-deliver.log
    auth_socket_path = /var/run/dovecot/auth-master
    postmaster_address = malmeida@itclinical.com
    mail_plugins = sieve
    mail_plugin_dir = /usr/lib/dovecot/modules/lda
    global_script_path = /etc/sieve/globalsieverc
    sieve_before = /etc/sieve/sieve_before
    sieve = file:~/sieve;active=~/.dovecot.sieve

}

I touched the /home/someuser/.dovecot.sieve to create the file, created the directory ~/sieve, and created /home/someuser/someuser.sieve with the contents:

require ["fileinto"];

if address :domain :is "From" "gmail.com" {
  fileinto "XXX";
  stop;
}

However, mail comming from a gmail account is being filed in INBOX instead of XXX.

EDIT:
In a nutshell, the use case I am interested is:

As an admin of a postfix configuration with one Mailbox per linux system user

I want one sieve rules file per user (in their home directory) in addition to the default global rules

So that each user's rules are separated (easier to read) and each use can configure his own rules

Edit 2018-08-29:
It ended up working by having:

  • a symlink ~/.dovecot.sieve pointing to /home/malmeida/sieve/name.sieve
  • The script in ~/sieve/name.sieve
  • Note that if the script has a different name, dovecot will log (e.g. if file is called active_sieve) " Warning: sieve: file storage: Active Sieve script symlink /home/user/.dovecot.sieve is broken: Invalid scriptname (points to /home/user/sieve/active_sieve)."

Best Answer

Sieve has a concept of active sieve script. The .dovecot.sieve is not a directory, but should be symbolic link to the active sieve script.

In other words:

  • ~/sieve may contain several scripts
  • ~/.dovecot.sieve should be a symlink to one of these scripts

With this setup, dovecot will be able to use the per-user configuration based on the files within each user's home directory.

Related Topic