[Dovecot] Using a Sieve script to handle delivery to public mailboxes
Hello everyone, I'm setting up a Postfix+Dovecot stack with virtual domains and public mailboxes.
I set up a shared mailbox "office@mydomain.com" as described in the Dovecot Wiki [1], that is:
- I created the directory "/var/mail/mydomain.com/public/" and inside it I created the ".office" mailbox;
- I added an appropriate ACL to allow the account "president@mydomain.com" to read and edit that mailbox under a public namespace;
- I added a Sieve script to handle delivery to the public mailbox (its location is /var/mail/mydomain.com/public/.office/.dovecot.sieve).
Some other relevant details about my configuration:
- The backend used by Postfix and Dovecot to handle virtual aliases/domains/maps is a MySQL database. Since the virtual user table is used by other applications as well, I decided to keep it "clean" and to make use of another "virtual mailboxes" table (see /etc/dovecot/dovecot-sql.conf.ext below). The password_query setting returns only results from the virtual user table (so that only real users can authenticate on the IMAP server), while the user_query setting returns results from both the virtual user and the virtual mailbox table (so that dovecot-lda can choose the correct mailbox).
- The queries saved in password_query and user_query return the correct results when executed manually: the home directory for the "office@mydomain.com" virtual mailbox is set to /var/mail/mydomain.com /public/.office.
- Delivery from and to the "president@mydomain.com" account is regular, and that account is able to access the "office@mydomain.com" virtual mailbox (I have tested this by speaking IMAP to the server and by performing a manual check using Thunderbird).
I encountered a problem with this setup: when I send a message to the "office@mydomain.com" account, the Postfix logs say it is correctly delivered via Dovecot, but the Sieve script says it can not find the folder "Public/.office". As a consequence, Dovecot creates a new Maildir in /var/mail/mydomain.com/office and delivers the mail there instead of saving it in the correct directory (/var/mail/mydomain.com/public/.office).
Is there something I set incorrectly in my configuration? What is causing Dovecot not to recognize the correct mailbox during delivery? Is there a way to list all mailboxes seen by dovecot-lda itself?
Thanks, Alessandro Menti
[1] http://wiki2.dovecot.org/SharedMailboxes/Public
Dovecot and OS version: 2.0.19, Ubuntu 12.04 LTS Output of "dovecot -n":
/etc/dovecot/dovecot-sql.conf.ext:
Extract from /var/log/mail.log:
Extract from /var/log/dovecot-lda.log:
Extract from /var/mail/mydomain.com/public/.office/.dovecot.sieve.log:
sieve: info: started log at Mar 15 11:43:07. error: msgid=<20140315104307.3BA221FFD1@mail.mydomain.com>: failed to store into mailbox 'Public/office': Mailbox doesn't exist: office.
Listing of /var/mail/mydomain.com/public/.office:
Contents of /var/mail/mydomain.com/public/.office/.dovecot.sieve:
require "fileinto"; fileinto "Public/office";
ACL for the "office" shared mailbox:
$ sudo cat /var/mail/mydomain.com/public/.office/dovecot-acl user=president@mydomain.com lrwstipe
Transcript of an IMAP session listing all folders:
On 3/15/2014 2:57 PM, Alessandro Menti wrote:
[...]
I must say I haven't tried using Sieve with public folders so far. However, I cannot quite imagine why this wouldn't work. Can you successfully append messages to the public folder through IMAP?
Regards,
Stephan.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Sat, 15 Mar 2014, Alessandro Menti wrote:
Dear Alessandro,
see below mail_location, SQL query and debug output ... .
IMHO, the behaviour matches your config.
^^^ default maillocation /var/mail/<domain>/office/Maildir
The UserDB query does _not_ return mail, hence, does not override default mail_location, which does _not_ depend on HOME.
^^ This matches the UserDB query, but is not used by mail location.
^^ This matches the default mail_location
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUBUylCKXD1/YhP6VMHAQIPJwf/Ti25u4nPcL86QjNGeFjION9OfgNtg/XD HQ1YKLjn6usuIrBJdnNczNdBMvDrOlONmyMLOyVfLaVEREIULCb80QrSbA41eW02 UMUXo+l41QedY2O32AnHN3ugsgOJXcLQLAXsRMqehyQa5BooyWiO6xo9fzkDiqX1 nd38ubYxn2EDIuGAeHwRDtgpX/s25FZeRvsUJrFPvo7eNOePyZY3qfq8m2/LrNet AyDWh3Hon7znj64LOtgr501tuq+HMFOBH40Qmd6kkFZFRwoBxdTDnmv9qrrwVvKx 2T5/hQBzD5LWAKGEF1+MTt00sYzQHoLRzCkfVgaSQjsG1butXRJRlQ== =xKsq -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Wed, 19 Mar 2014, Steffen Kaiser wrote:
IMHO, the behaviour matches your config.
If my assumption in my previous message is correct, you will have some options:
a) have UserDB return "mail", b) make mail_location depend on home via ~ c) create a symlink default location -> public d) forward office to some other user where you use "fileinto Public/office" e) ...
Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUBUylECXD1/YhP6VMHAQLf4gf8CgYvrxmeMcsFSHzo96cAfVjG9PeovQ+q x64muAIY+dm5UtsIQVU/1Ou8Srrq426J2znGAfY1WGsuAGNp9hKswPJxCYevJv7U sXb46EQShtxo6kj98eewc0avD7C9EA076b+dl0ETyvIRklKNcjsGgrHuL6PGgM8D WTF3FINwP7uKOr8BDi5ILS93arS0OFzLspLcpu6y59Z+uc0OKlf6aV9NKLD+iUsP wy3lx73TBneqhuUTpLUekZ2DWYnibNJeupHkb2mQte3u+uCISE7oDodhyaS9hii0 SLawE8I7e8jcfjUOp3k3AGzQoikgLOeptYge64748ppiR3YinT7nrg== =ETqR -----END PGP SIGNATURE-----
Il 19/03/2014 08:15, Steffen Kaiser ha scritto:
Thanks - I mistakenly thought for some unknown reason that returning just "home" from the UserDB query had effect on the user's mail location as well.
I added a "mail" column to the database tables and edited the userdb_query to make it return "user" as well - now everything is fine.
Thank you very much again for your help! Alessandro Menti
A neutron walks into a bar and asks how much for a drink. The bartender replies "for you, no charge". -- Sheldon Cooper, The Big Bang Theory
participants (3)
-
Alessandro Menti
-
Steffen Kaiser
-
Stephan Bosch