After Google closed the Reader, I lost faith in a big company that makes me a tool for solving important tasks for me. I decided to build my own Luna Park with readers, aggregators, bolters, etc. Mail on your domain is the first thing that comes to mind. It’s not a question to register the MX record, put Postfix on local delivery, install the Dovecot IMAP server and Roundcube webmail client, the question is to repeat the functionality of the “big” system, first of all, sorting. I will not duplicate the existing instructions, I will describe only non-obvious points.
What does not suit me in Gmail? This is the ideology of labels, which can be attached to the same letter several, and in IMAP to display them in the form of folders. As a result, the root folder is always full of letters, and I am such a person (perhaps my case is unique) that I delete all the “extra” mail, and put all the “necessary” mail into folders. I erase all notifications from web stores, forums, services, etc., that do not fit Google’s ideology “why remove if the place is infinite?”. Google wants to see as much as I can, but I do not want to see trash. Further, I used iCloud / me.com, everything is simple there: the rules for sorting incoming mail just don't work and that's all.
So, the task is: for Dovecot to arrange mail in IMAP folders. Honestly, I spent about 20 minutes searching for “where's the filtering settings for Roundcube?”, And then I started reading instructions. Unfortunately, everything that can be found on the web does not contain a complete list of rakes that can be stepped on, I will try to describe them here without hesitation.
First, you need to learn the word
sieve , this is a whole language for the description of filtering rules, created by Cyrusoft while working on the Cyrus mail server (it will not be remembered by the night). It allows you to write such self-evident rules:
')
require ["fileinto"];
Of course, I don’t really want to go to the console to write a new filtering rule, fortunately, there is a managesieve protocol that allows the email client to steer the rules on the server. Fortunately, both Dovecot and Roundcub support both features. And then, start the rake.
First of all, the simplest and most natural thing that is done to enable seive is setting mail_plugins = sieve somewhere globally for the entire Dovecot. It is not right! It will be like this:
Error: dlopen(/usr/lib64/dovecot/lib90_sieve_plugin.so) failed: /usr/lib64/dovecot/libdovecot-sieve.so.0: undefined symbol: mail_deliver_get_log_var_expand_table
The variable should be set in /etc/dovecot/conf.d/15-lda.conf, for lda, local delivery. The inclusion of managesieve in Dovecot and Roundcube does not cause problems (plug-ins are in the standard package), you just have to remember to register the port. You can start writing rules, they will not work, because although the mail is expanded in the folder from the client, the “local delivery agent” is still Postfix and INBOX not in / home / username, but in / var / mail / username. You must add mailbox_command = / usr / lib / dovecot / deliver -d "$ USER" to main.cf. Now it seems that everything is fine: almost all letters are arranged according to almost all the rules. I spent the day trying to find out why the mail does not fall into the folder and took my colleagues out of myself with my experiments. I thought that I incorrectly describe the properties of the header, since there the envelope and delivery data are different (because the communication takes place on the mailing list server, and everything should look like from the other person to the interlocutor). Then I saw an error:
Mar 16 17:53:01 DJBZ002 dovecot: lda(shaman007): Error: write() failed with mbox file /home/shaman007/mail/INBOX/LOR: File too large (process was started with ulimit -f limit) Mar 16 17:53:01 DJBZ002 dovecot: lda(shaman007): Error: sieve: msgid=<d068a42487535146ce3e7ec8b6557b27@andreybondarenko.com>: failed to store into mailbox 'INBOX/LOR': Internal error occurred. Refer to server log for more information. [2013-03-16 17:52:57] Mar 16 17:53:01 DJBZ002 dovecot: lda(shaman007): sieve: msgid=<d068a42487535146ce3e7ec8b6557b27@andreybondarenko.com>: stored mail into mailbox 'INBOX' Mar 16 17:53:01 DJBZ002 dovecot: lda(shaman007): Error: sieve: execution of script /home/shaman007/.dovecot.sieve failed, but implicit keep was successful (user logfile /home/shaman007/.dovecot.sieve.log may reveal additional details) Mar 16 17:53:01 DJBZ002 postfix/local[13359]: 4575811F76E: to=<shaman007@andreybondarenko.com>, orig_to=<me@andreybondarenko.com>, relay=local, delay=3.9, delays=0.21/0.02/0/3.7, dsn=2.0.0, status=sent (delivered to command: /usr/libexec/dovecot/dovecot-lda -f "$SENDER" -a "$RECIPIENT") Mar 16 17:53:01 DJBZ002 postfix/qmgr[29435]: 4575811F76E: removed
File too large! As many as 100 megabytes! It turned out that although it triggers a Dovecot error, the point is Postfix’s mailbox_size_limit parameter. By default, there are 5 megabytes of something, you need to set it to 0. It seems this is all a rake.