1

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)."
mmalmeida
  • 155
  • 1
  • 9

1 Answers1

4

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.

mmalmeida
  • 155
  • 1
  • 9
cmouse
  • 488
  • 3
  • 10
  • Thanks for the input. Just for clarification before accepting this answer - does that mean that the sieve directory may only include one file, and that .dovecot.sieve should symlink to that file? – mmalmeida Apr 19 '18 at 08:12
  • Also, for clarification - is the interpretation correct that the "sieve =" directory with a "~/" notation is used to access per-email-user directives, based on what each user has on his ~/ directory? – mmalmeida Apr 19 '18 at 16:50
  • You can have more than one file, but only one can be active at a time, which the symlink points to. doveadm sieve can be used to manipulate these with recent enough dovecot. At least 2.2.0 or later. – cmouse Apr 20 '18 at 12:45
  • Thanks for the pointers. I updated my answer and will accept this one! – mmalmeida Aug 29 '18 at 11:31