Setting up Dovecot

This chapter of our journey leads us to Dovecot – the software that…

  • gets emails from Postfix and saves them to disk
  • executes user-based “sieve” filter rules (can be used to e.g. move emails to different folders based on certain criteria or send automated vacation responses)
  • allows the user to fetch emails using POP3 or IMAP

Before we get to the actual configuration for security reasons I recommend that you create a new system user that will own all virtual mailboxes. The following shell commands will create a system group “vmail” with GID (group ID) 5000 and a system user “vmail” with UID (user ID) 5000. (Make sure that UID and GID are not yet used or choose another – the number can be anything between 1000 and 65000 that is not yet used):

groupadd -g 5000 vmail
useradd -g vmail -u 5000 vmail -d /var/vmail -m

If the /var/vmail directory was already there because you assigned it a dedicated mount point then you should make sure that the permissions are set correctly:

chown -R vmail.vmail /var/vmail

The configuration files for Dovecot are found in /etc/dovecot/conf.d/. All these files are loaded by Dovecot. This is done by this magical line in the dovecot.conf file:

!include conf.d/*.conf

It loads all files in /etc/dovecot/conf.d/ that end on “.conf” in sorted order. So “10-auth.conf” is loaded first and “90-quota.conf” is loaded last. The big advantage is that you can edit or replace parts of the configuration without having to overwrite the entire configuration. The main /etc/dovecot/dovecot.conf file does not require any changes. Those other files in conf.d/ however need to be edited…

conf.d/

10-auth.conf

If your users are still using Outlook Express (Windows XP) or Microsoft Mail (Windows Vista) then you need to add the “LOGIN” authentication mechanism in addition to the standard “PLAIN” mechanism:

auth_mechanisms = plain login

These are plaintext (unencrypted) ways to transmit a mail user’s password. But don’t worry. By default Dovecot sets “disable_plaintext_auth = yes” which ensures that authentication is only accepted over TLS-encrypted connections.

At the end of this file you will find various authentication backends that Dovecot uses. By default it will use system users (that are listed in /etc/passwd). But we want to use the MySQL database backend so go ahead and change this block to:

#!include auth-system.conf.ext
!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
#!include auth-static.conf.ext

Now edit the SQL configuration file:

auth-sql.conf.ext

Change the “userdb” section to:

userdb {
  driver = static
  args = uid=vmail gid=vmail home=/var/vmail/%d/%n
}

The placeholder %d stands for the domain part and %n for the user part if you have an email address like “user@domain”. Dovecot’s variables are documented on their website.

10-mail.conf

Change the mail_location setting to:

mail_location = maildir:/var/vmail/%d/%n/Maildir

This is the directory where Dovecot will look for the emails of a specific user. So for john@example.org this leads to “/var/vmail/example.org/john/Maildir”.

Further down you will find sections defining the namespaces. These namespaces are folder structures that your email program sees when connecting to the mail server. If you use POP3 you can only access the “inbox” – which is where all incoming email is stores. Using the IMAP protocol you get access to a hierarchy of folders and subfolders. And you can even use folders shared between users. Or public folder that could be accessed by anyone – even anonymously.

Look for the “namespace inbox” section. If you already have emails stored on your server from previous versions of this ISPmail guide you need to change:

separator = .

here. By default the seperator is “/” which creates a directory structure like “/var/vmail/example.org/john/Maildir/INBOX/staff/marketing/simon”. This is perfectly fine. But previous ISPmail guides used “.” as a seperator so the mentioned folder would rather have been “/var/vmail/example.org/john/Maildir/.INBOX.staff.marketing.simon”.

10-master.conf

This configuration file deals with services that allow communication with other processes. For example it enables or disables POP3 or IMAP. Don’t worry about the standard unencrypted TCP ports 110 (for POP3) and 143 (for IMAP). They can be kept accessible. If a user connects to these ports they will have to issue a STARTTLS command to switch into encrypted mode before they are allowed to send their password. There is basically no difference between using an plaintext port like 110 for POP3 and then using STARTTLS – or connecting to the encrypted 995 port for POP3S (=secure). See the Dovecot documentation for another explanation.

So most settings are sane here and do not have to be changed. However one change is required in the “service auth” section because we want Postfix to allow Dovecot as an authentication service. This is what has to be entered:

# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
  mode = 0660
  user = postfix
  group = postfix
}

Why that strange path? Well, Postfix runs in a chroot environment located at /var/spool/postfix. It can’t access anything outside of that directory. So to allow communication with Postfix we tell Dovecot to use the communication socket file in that chroot area.

10-ssl.conf

Earlier in this guide you created both a key and a certificate file to encrypt the communication with POP3, IMAPs and HTTPS between the users and your mail server. You need to tell Dovecot where to find these files:

ssl_cert = </etc/ssl/certs/mailserver.pem
ssl_key = </etc/ssl/private/mailserver.pem

And enable TLS/SSL encryption by setting:

ssl = yes

You could also set “ssl=required” but as Dovecot disallows sending plaintext passwords over unencrypted connections anyway we don’t actually need it. See the Dovecot documentation on SSL encryption for more information.

15-mailboxes.conf

You should also add these lines within your “namespace inbox” section:

 mailbox INBOX.Junk {
  auto = subscribe
  special_use = \Junk
 }
 mailbox INBOX.Trash {
  auto = subscribe
  special_use = \Trash
 }

It ensures that a “Junk” and a “Trash” folder are created within the inbox when a user logs in. The user is also automatically subscribed to these folders. (When using IMAP you can choose which folder you want to see by subscribing them.) The “Junk” folder is required so that we can move spam emails to it – we will configure that later. And the “Trash” folder is required so that users using the Roundcube web mailer can actually delete emails.

The names used in “special_use” refer to the special-use mailboxes as described in the RFC 6154.

/etc/dovecot/dovecot-sql.conf.ext

This file is referred to by /etc/dovecot/conf.d/auth-sql.conf.ext. It tells Dovecot how to access the MySQL database and where to find the information about email users/accounts. You will find it well documented although all configuration directives are commented out. Add these lines at the bottom of the file:

driver = mysql
connect = host=127.0.0.1 dbname=mailserver user=mailuser password=ChangeMe  <- use your database access password instead
default_pass_scheme = SHA256-CRYPT
password_query = SELECT email as user, password FROM virtual_users WHERE email='%u';

What these lines mean:

  • driver: the kind of database
  • connect: where to find the MySQL database and how to use it (username, password)
  • default_pass_scheme: the format in which the passwords are stored (we use strong salted SHA256 hashes)
  • password_query: an SQL statement that returns the user (=the email address) and the password (SHA256 hash) from the database where “%u” is the login user name (=we use the email address as the user name of an email account). Whenever Dovecot needs to check an email user’s password if will run the above query and verify the password against the hash in the database.

Finishing move

You should also make sure that only root can access the SQL configuration file so nobody else is reading your database access passwords:

chown root:root /etc/dovecot/dovecot-sql.conf.ext
chmod go= /etc/dovecot/dovecot-sql.conf.ext

Restart Dovecot from the shell:

service dovecot restart

Look at your /var/log/mail.log logfile. You should see:

... dovecot: master: Dovecot v2.2.13 starting up for imap, sieve, pop3 (core dumps disabled)

If you get any error messages please double-check your configuration files.

60 thoughts on “Setting up Dovecot

  • 2015-10-29 at 09:26
    Permalink

    Thank you Haas for another wonderful tut. Been following since the Wheezy guide. I do have some small questions though. Why is the auto-created/subscribed folders “Trash” and “Junk” created in 10-mail.conf? Can the same be done in 15-mailboxes.conf? There already seems to be similar code written there.

    Also, what is the difference between the mailbox name you’ve written “INBOX.Junk” and the normal Junk name in the following code?
    mailbox Junk {
    auto = subscribe
    special_use = \Junk
    }

    Reply
    • 2015-10-29 at 09:44
      Permalink

      Hi Pavin… (my first name is “Christoph”). Glad to have you as a regular customer. 🙂

      Whether you define the mailboxes in 10-mail or 15-mailboxes does not matter. But I wonder indeed whether I accidentally defines the Junk folder twice. I believe it should belong into 15-mailboxes – I will verify that in my test installation.

      The difference between “Junk” and “INBOX.Junk” is that “Junk” is parallel to the inbox. And “INBOX.Junk” is a folder underneath the inbox. The “.” is used because that’s our path separator.

      Reply
      • 2015-11-15 at 00:19
        Permalink

        Hi Christoph,
        You mention here that it’s INBOX.junk because that is the path separator we use, however, that’s the case when upgrading from a previous version of the ispmail-guide. Since I’m a new user, shouldn’t I use INBOX/junk instead?

        Reply
        • 2015-11-15 at 00:27
          Permalink

          Hi Hertog. If your “seperator” is set to “/” (the default) or not defined then it’s INBOX/Junk – right.

          Reply
          • 2015-11-24 at 07:51
            Permalink

            Thanks Hertog and Christoph, I nearly fell for the INBOX.xxx, as I have used other mailservers that defaulted to “.”. I left this one as default”/”, so I went back and changed that.

          • 2016-06-14 at 13:33
            Permalink

            Wow – fell for this one too.

  • 2015-10-29 at 16:05
    Permalink

    Hi Christoph,

    First thanks for all the ISP manuals you’ve written. I have used them all.
    Second, maybe I’ve missed it, but I was missing something like: chown vmail:vmail /var/vmail, since my test mail failed.

    Regards,
    Richard

    Reply
    • 2015-10-29 at 16:07
      Permalink

      Richard, thank you, too, for being a frequent buyer. 😉 I deliberately threw the “chown” out because

      useradd -g vmail -u 5000 vmail -d /var/vmail -m

      does that already. It creates /var/vmail with ownership and group membership of “vmail”. I tested that twice. Could it be you chose a different order than described in the guide?

      Reply
  • 2015-10-30 at 09:33
    Permalink

    Hi Christoph,
    I checked my history and I followed the described order. I only created logical volumes, including the /var/vmail. Since the directory (and mount point) already existed, probably the ownership hasn’t been applied. When I’m testing it on an existing directory I’ll get an error (directory already exist). I can’t remember getting an error while adding vmail… When I’ve time, I will test it in a better way.

    Thanks for your response!
    Regards,
    Richard

    Reply
  • 2015-11-02 at 08:52
    Permalink

    Hi,
    Can you please help me,
    When i ran this command groupadd -g 5000 vmail
    message
    groupadd: group ‘vmail’ already exists

    Reply
    • 2015-11-02 at 08:57
      Permalink

      Hi Babu. Are you sure that yu are doing the installation on a new server?

      Reply
      • 2015-11-02 at 17:37
        Permalink

        Yes.
        But when I browse the site i am getting
        Forbidden

        You don’t have permission to access / on this server.
        Apache/2.4.10 (Debian) Server at 192.168.0.100 Port 443

        Reply
        • 2015-11-03 at 09:51
          Permalink

          Please check your /var/log/apache2/*.log for error messages.

          Reply
  • 2015-11-03 at 06:36
    Permalink

    root@mailserver:/etc/apache2/sites-available# useradd -g vmail -u 5000 vmail -d /var/vmail -m
    useradd: warning: the home directory already exists.
    Not copying any file from skel directory into it.

    Reply
    • 2015-11-03 at 08:03
      Permalink

      You get that warning if you created the /var/vmail directory before you add the user. That usually happens when you mounted /var/vmail as a seperate file system. The warning is just telling you that it did not create the home directory. The skeleton files should not be copied anyway. I didn’t find an option for “useradd” though to skip copying the files.

      Reply
      • 2015-11-03 at 16:10
        Permalink

        root@mailserver:/etc/apache2/sites-available# useradd -g vmail -u 5000 vmail -d /var/vmail -m
        useradd: warning: the home directory already exists.
        Not copying any file from skel directory into it.

        That means
        something wrong with partitioning ?
        That’s it. All partitions are now created. Finish the partitioning…
        while creating i don’t see an option for /var/vmail. is that is creating this issue?

        Reply
        • 2015-11-03 at 16:16
          Permalink

          As I said. Can be ignored safely.

          Reply
  • 2015-11-04 at 20:07
    Permalink

    Now I get connect connect to storage error

    Reply
  • 2015-11-05 at 15:47
    Permalink

    thank you.
    chown vmail:vmail -R /var/vmail/

    Reply
    • 2015-11-06 at 08:45
      Permalink

      Thanks. Just fixed the link.

      Reply
  • 2015-11-06 at 15:06
    Permalink

    Hello,

    first thank you for this good tutorial. But, my question is why not not consider to use the Dovecot LMTP for the mail transmission as in fact LMTP is considered more stable and has more value to offer in comparison to lda.

    greetings,
    dominik

    Reply
    • 2015-11-08 at 14:57
      Permalink

      Thanks for the thought, Dominik. In fact I wanted to switch to LMTP anyway but somehow it disappeared from my todo list. I’ll change that.

      UPDATE: The Jessie guide now uses LMTP instead of the LDA.

      Reply
      • 2015-11-25 at 13:36
        Permalink

        Dear Christof,

        I’m just realized the switch from LDA to LMTP. As my server was set up before this change and it’s working fine, do you suggest to make the change? Should I just follow the new instructions in “Making Postfix send emails to Dovecot”, right?

        Danke schön!

        Reply
        • 2015-11-25 at 15:02
          Permalink

          Hi Martin. It’s not necessary to change anything. LMTP is just a bit simpler to set up and has a tiny bit less overhead. But using LDA is perfectly fine if your mail server is already in production and you don’t want a downtime.

          Reply
  • 2015-11-06 at 17:23
    Permalink

    Hello
    Dovecot dont starting :

    Nov 6 12:19:46 jessie dovecot[24404]: doveconf: Fatal: Error in configuration file /etc/dovecot/conf.d/90-acl.conf line 11: Unknown setting: plugin
    Nov 6 12:19:46 jessie systemd[1]: dovecot.service: main process exited, code=exited, status=89/n/a
    ???
    thanks

    Reply
    • 2015-11-09 at 12:05
      Permalink

      Did you change anything there? I could otherwise just imagine that a typo from a previous configuration file turned into that error message. If in doubt I suggest you remove and purge the Dovecot packages again (apt-get –purge remove dovecot*) and do the Dovecot configuration from scratch. It could be something as simple as a missing bracket.

      Reply
  • 2015-11-09 at 18:49
    Permalink

    Thanks Christoph , set up from scratch was the solution. My server is perfect, more faster the previous with wheezy. My server is now in production with 100 users. Thanks .
    Greetings from Peru

    Reply
    • 2015-11-10 at 12:48
      Permalink

      Very cool to hear that. You are invited to tell that on the “success stories” page to let others know.

      Reply
  • 2015-11-19 at 21:40
    Permalink

    Thank you for sharing your knowledge.
    I would like to have your opinion about different ways that dovecot use to store data.
    Maildir, Dbox and Mdbox.

    Sure, already documented on Dovecot WIki but i would have a more pratical opinion, pro and cons in your setup.

    Another interesting comments could be regarding Active DIrectory authentication and specifically with a distributed environment with multiple child domains.

    The idea behind is to let users to authenticate on your intended child domain controller or let dovecot and postifix to browse the entire forest.

    After, in a geographic and distributed environment it would be great to replicate parts of the storage and create a local replica of the necessary components in order to:
    -> speed up the users access(in some country its really difficult to reach servers located elsewhere)
    -> reduce the workload

    Some thoughts:
    -> glusteFS or anything else to replicate(just some mailbox or some domains)
    -> dovecot+roudcube in every server location
    -> a central mail server where postifix deliver all mails

    Does it sounds crazy?

    Thank you

    Reply
  • 2015-11-20 at 01:16
    Permalink

    a working user_query for /etc/dovecot/dovecot-sql.conf.ext is:

    user_query = SELECT concat(‘/var/vmail/’, email) AS home, \
    5000 AS uid, 5000 AS gid FROM virtual_users WHERE email = ‘%u’

    Reply
  • 2015-12-20 at 17:24
    Permalink

    Dear Christoff,

    I am getting this all the time:

    Dec 20 17:20:45 Beastie dovecot: auth: Fatal: mysql: Missing value in connect string: <-
    Dec 20 17:20:45 Beastie dovecot: master: Error: service(auth): command startup failed, throttling for 16 secs
    Dec 20 17:20:45 Beastie dovecot: imap-login: Disconnected: Auth process broken (disconnected before auth was ready, waited 0 secs): user=, rip=127.0.0.1, lip=127.0.0.1, secured, session=

    Can you tell me what I have done wrong please?

    Reply
    • 2015-12-20 at 17:28
      Permalink

      It’s probably a bit misleading. But you are supposed to leave out the ” <- use your database access password instead" part. That's just a comment.

      Reply
  • 2015-12-20 at 18:02
    Permalink

    Thanks – I just spotted that (how embarrassing) now I am getting this…

    root@Beastie:/etc/dovecot/conf.d# service dovecot restart
    stop: Unknown job: dovecot
    start: Unknown job: dovecot

    I have reloaded Dovecot – I didn’t see this message before, but that doesn’t mean it was not there. I cannot connect to roundcube – I get:

    Connection to IMAP server failed.

    I am now stuck…….

    Reply
  • 2015-12-21 at 15:10
    Permalink

    This may help, I think I should start Dovecot with just the command “dovecot”

    But now I get “login failed” when I try to login with Roundcube, which is progress of sorts…… and there are no entries in the /var/log/mail.err or mail.log files.

    I think I will look again tomorrow at this, tiredness is creeping in.

    UPDATE:

    Now I can login but I am getting this when I do:

    SERVICE CURRENTLY NOT AVAILABLE!

    Error No. [500]

    Reply
  • 2015-12-21 at 15:24
    Permalink

    … and this in the mail.log:

    Dec 21 15:21:32 Beastie dovecot: imap-login: Login: user=, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=32386, secured, session=
    Dec 21 15:21:32 Beastie dovecot: imap(alan@bgc-cloud.co.uk): Disconnected: Logged out in=29 out=466

    I am now stuck again……..

    Reply
  • 2016-01-09 at 01:48
    Permalink

    Not so interesting comment maybe but didn’t know the form [chown user.user file],
    knew only [chown user:user file]. Seems to be an older valid form.

    Learning everyday and Thanks a lot for your ISP series, Im also a regular buyer, since Squeeze;
    currently doing it on a Devuan-Jessy Proliant Server I got for cheap on auctions.

    Reply
  • 2016-03-02 at 17:20
    Permalink

    I have successfully completed the tutorial and am up and running on Debian Jessie in a test environment. I’m now trying to add functionality to purge Sent, Trash, and Junk folders of older messages.

    I planned to use a script run via cron to call doveadm expunge using the -A flag for all users:

    ex. doveadm expunge -A mailbox Junk savedbefore 60d

    Unfortunately the above fails because it cannot get a listing of users:

    “doveadm: Error: User listing returned failure” and “doveadm: Error: Failed to iterate through some users”

    I believe this is a result of using a static SQL query. I attempted uncommenting “iterate_query” in /etc/dovecot/dovecot-sql.conf.ext but I’m not sure if that is correct or what the correct query for “iterate_query” should be.

    Would really appreciate any help on how to get this working.

    Reply
  • 2016-03-10 at 17:49
    Permalink

    Your guide is EXCELLENT!
    I learnt a lot and went to the end (almost) flawlessy.
    I noticed that you lef out Dovecot MasterUsers (http://wiki2.dovecot.org/Authentication/MasterUsers) from the tutorial. it would be extremely useful for migration purposes.
    Was it intentional or do you think it can be an improvement to the howto?

    Reply
  • 2016-03-12 at 23:44
    Permalink

    Wonderful guide and I appreciate all the work you have done. I have been running my own email server at my house for 2-3 years now and this is the first time I tried using mysql with email. One problem I had was configuring the file /etc/dovecot/dovecot-sql.conf.ext with this line (connect = host=127.0.0.1 dbname=mailserver user=mailuser password=ChangeMe). I was getting errors of “Mar 12 17:23:31 server dovecot: auth-worker(2497): Error: mysql(127.0.0.1): Connect failed to database (mailserver): Access denied for user ‘mailuser’@’localhost’ (using password: YES) – waiting for 1 seconds before retry”.
    I had special characters in my password that caused my login to fail. The solution was to double quote from ‘host’ the end of ‘password’. I would suggest that the default would be to always double quote this configuration in the future. I took me several hours to figure this out since I didn’t know the intricacies of the syntax. I used http://wiki2.dovecot.org/AuthDatabase/SQL as a reference. Here is how I was able to get it to work, (notice the placement of the quotes): connect = “host=127.0.0.1 dbname=mailserver user=mailuser password=ChangeMe”. Thanks again Christoph!!!

    Reply
  • 2016-03-31 at 10:31
    Permalink

    Hi Christoph,

    I’m still getting errors. It appears that others have it too but so far there is no solution…

    Mar 31 11:26:51 baphomet dovecot: auth-worker(3418): Warning: mysql: Query failed, retrying: Table ‘mailserver.users’ doesn’t exist
    This site has a suggestion but for me it caused delivery failure….
    http://serverfault.com/questions/594974/dovecot-unable-to-perform-mysql-query

    The earlier suggestion by mendax causes more errors.

    Reply
    • 2016-08-13 at 18:38
      Permalink

      I had this problem and i solved it by doing 2 things:

      edit /etc/dovecot/dovecot-sql.conf.ext and insert the following:
      user_query = SELECT concat(‘/var/vmail/’, email) AS home, 5000 AS uid, 5000 AS gid FROM virtual_users WHERE email = ‘%u’

      edit /etc/postfix/main.cf and outcommenting the line:
      mydestination

      Reply
  • 2016-04-27 at 20:03
    Permalink

    Just a quick follow up on my comment on the page “Creating a TLS encryption key and certificate”. Dovecot requires you to combine the intermediate and your own certificate in a single pem file. In my comment this was called mailserver_with_chain.pem. If you use the pem file with only your own certificate you get the following when testing with openssl:

    # openssl s_client -CApath /etc/ssl/certs -connect localhost:imaps

    Verify return code: 21 (unable to verify the first certificate)

    But if you use the combined pem file you get:

    # openssl s_client -CApath /etc/ssl/certs -connect localhost:imaps
    Verify return code: 0 (ok)

    So I have in my 10-ssl.conf:

    ssl_cert = </etc/ssl/certs/mailserver_with_chain.pem
    ssl_key = </etc/ssl/private/mailserver.pem

    Reply
  • 2016-06-06 at 02:04
    Permalink

    Hi Christoph,
    It would be appreciated if there’s the guide for how to set mailbox quota.

    Reply
  • 2016-08-02 at 16:55
    Permalink

    looks like a lot of work has gone into this.
    it’s quite an ordeal getting an email server to work. without a good tutorial near impossible I would think. unless you’re a system admin. it would be helpful though to make an addendum on setting this up with nginx… is there any description available by your knowledge?

    Reply
    • 2016-08-03 at 11:13
      Permalink

      I’m running my personal mail server with Nginx. I “just” need to document the settings. Unfortunately I recently moved to a new place and currently I’m still stuck with cardboard boxes at the top of my todo list. 🙂

      Basically you set up Nginx with FastCGI and use a standard virtual host configuration and just add:

      location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      }

      The snippets file looks like this:

      /etc/nginx/snippets/fastcgi-php.conf
      # regex to split $uri to $fastcgi_script_name and $fastcgi_path
      fastcgi_split_path_info ^(.+\.php)(/.+)$;

      # Check that the PHP script exists before passing it
      try_files $fastcgi_script_name =404;

      # Bypass the fact that try_files resets $fastcgi_path_info
      # see: http://trac.nginx.org/nginx/ticket/321
      set $path_info $fastcgi_path_info;
      fastcgi_param PATH_INFO $path_info;

      fastcgi_index index.php;
      include fastcgi.conf;

      You’ll need the “nginx-extras” package for FastCGI support and the “php5-fpm” package. Please try that and let me know if it’s sufficient already. I’ll happily add that to the guide then.

      Reply
  • 2016-09-18 at 03:30
    Permalink

    Hi Christoph,

    working now for a while with my own private mail server on a small VPS. OpenSuse instead of Debian, as I love it for years. Smaller changes necessary, like different path names etc., but no real problems.

    One question, independent of distro: Following your DOVECOT recommendations on this page, I’ve added e.g.

    mailbox INBOX.Trash {
    auto = subscribe
    special_use = \Trash
    }

    to 15-mailboxes.conf.

    Doing this I’ve recognized the following behaviour of Android’s 4.4.2 (kitkat) AOSP email client:

    – For my private Dovecot’s IMAP accounts these “mailboxes” are shown as folders in INBOX. Which sound reasonable at first, as in fact they are INBOX., BUT: The special_use folders are not used as they should. E.g. when I delete an email within AOSP email client, (latest then) a new folder “Trash” is created on “root” level of IMAP structure. And the “deleted” email is moved to this root level folder “\Trash”, not (as wanted) into “INBOX.Trash”.

    – Whyever, when using my Deutsche Telekom / T-Online Email Account, I can see/verify in Thunderbird that Deutsche Telekom’s Dovecot uses the sames structure (INBOX.Trash, INBOX.Drafts, INBOX.Sent) than my private one, but for my T-Online account my AOSP email client “detects” all folders as special folder, as they should be used.

    Don’t have any “IMAP path prefix” etc. defined.

    But checked any combination of INBOX, inbox, Inbox, for namespace and path prefix. Does not help, only effect is that that INBOX.* subfolders are going hidden in AOSP email client depending on path prefix set.

    Any idea what could be the “magic” difference between Deutsche Telekom’s Dovecot settings and ours/your recommendation?

    Thanks in advance,
    Michael

    Reply
    • 2016-11-06 at 23:25
      Permalink

      As no one answered maybe not of interest for anyone 🙂

      But I’ve found the root cause, it’s the imcomplete an buggy implementation of Android AOSP’s email client. K9-Mail on Android works fine with the folders defined a suggested in this great IPSmail tutorial

      Reply
  • 2016-10-22 at 04:57
    Permalink

    Hi Christoph,

    First of all thank you for this guide.

    I am encountering an issue when trying to login roundcube. I am getting the ‘Connection to storage server failed.’ I have done some troubleshooting and I would appear the issue is with the syntex in dovecot-sql.conf.ext line 144. Unknown setting: password (password=ChangeMe) I have also tried this with spaces either side of the =, but still the same error.

    Please could you advice what this could be?

    Kind Regards,

    Matt H

    Reply
    • 2017-03-07 at 20:14
      Permalink

      Hey Matt!
      I had the exact same problem. Like me, you probably reading this on a narrower screen, so you saw a line break in the code and typed one by hand, but actually there is none. Write everything from “connect =” until “password=changeme” in the same line of dovecot-sql.conf.ext

      Hope this helps

      Reply
  • 2016-10-25 at 20:16
    Permalink

    Hi Christoph

    Good afternoon, dear friend, infinitely agradesco the work that you have taken in creating this tutorial.

    The material you have developed is very explicit, the only real barrier that I’ve had is the language.

    I write with the news that Roundcube have problems to connect to the IMAP server, I have reviewed about six times the Dovecot configuration having the same results.

    Everytime I log the user interface and passwords wing by roundcube get out “error connection to the imap server”
    I transcribe acontinuacion output -n command dovecot

    root @ www: / etc / postfix # dovecot -n
    # 2.2.13: /etc/dovecot/dovecot.conf
    # OS: Linux 3.16.0-4-686-pae i686 Debian 8.6 ext4
    auth_mechanisms = plain login
    mail_location = maildir: / var / vmail /% d /% n / Maildir
    {namespace inbox
    inbox = yes
    location =
    Drafts mailbox {
    special_use = \ Drafts
    }
    INBOX.Junk mailbox {
    auto = subscribe
    special_use = \ Junk
    }
    INBOX.Trash mailbox {
    auto = subscribe
    special_use = \ Trash
    }
    Junk mailbox {
    special_use = \ Junk
    }
    Sent mailbox {
    special_use = \ Sent
    }
    mailbox “Sent Messages” {
    special_use = \ Sent
    }
    Trash mailbox {
    special_use = \ Trash
    }
    prefix =
    }
    passdb {
    args = /etc/dovecot/dovecot-sql.conf.ext
    driver = sql
    }
    protocols = “imap pop3 lmtp”
    auth service {
    unix_listener / var / spool / postfix / private / auth {
    group = postfix
    mode = 0660
    user = postfix
    }
    }
    lmtp service {
    unix_listener / var / spool / postfix / private / dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
    }
    }
    ssl_cert = </etc/ssl/certs/mailserver.pem
    ssl_key = </etc/ssl/private/mailserver.pem
    userdb {
    args = uid = gid = vmail vmail home = / var / vmail /% d /% n
    driver = static
    }
    lmtp protocol {
    mail_plugins = "sieve"
    }

    I've gone over again and again Dovecot settings and configuration file: /var/www/html/webmail/config/config.inc.php

    $ Config = array ();

    $ Config [ 'db_dsnw'] = 'mysql: // my_username: Password @ localhost / mail';

    $ Config [ 'default_host'] = 'localhost';

    $ Config [ 'smtp_server'] = 'mi_dominio.ve';

    $ Config [ 'smtp_port'] = 25;

    $ Config [ 'smtp_user'] = 'mailuser';

    $ Config [ 'smtp_pass'] = 'smtp_contraseñas';

    $ Config [ 'SUPPORT_URL'] = '';

    $ Config [ 'product_name'] = 'Roundcube Webmail';

    $ Config [ 'des_key'] = 'M13LX2016 = 5Tc4j2d2s / X / $';

    // List of active plugins (in plugins / directory)
    $ Config [ 'plugins'] = array (
    'Archive'
    'Zipdownload'
    'Managesieve'
    'Password'
    );

    // Skin name: folder from skins /
    $ Config [ 'skin'] = 'larry';

    // Leguage of Spanish interface
    $ Rcmail_config [ 'language'] = 'en_US';

    // The duration of the secion is 60 minutes
    $ Config [ 'session_lifetime'] = 60;

    Reply
  • 2017-01-16 at 13:45
    Permalink

    I didn’t see this line anywhere in /etc/dovecot/dovecot.conf, so i added it myself, is that what you mean to do?

    !include conf.d/*.conf

    restarting dovecot didn’t give me the line you show above about starting for imap pop3 etc, but it didn’t give me any errors either.

    Reply
  • 2017-01-22 at 16:44
    Permalink

    The correct (read secure) order of doing things is to first make the config file readable only to root and only then store your database password in there. Just saying. Idem for the postfix config files.

    Reply
  • 2017-01-24 at 14:55
    Permalink

    OK, hoping someone can help me here… following the instructions to the letter yet I keep getting this same error when I check the logs /var/log/mail.log. I can occasionally get it to go with a reboot of the server or strangely enough by changing the root password. Here is the log:

    Jan 24 22:50:29 MyServersName dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
    Jan 24 22:50:29 MyServersName dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
    Jan 24 22:50:29 MyServersName dovecot: master: Dovecot v2.2.13 starting up for imap, lmtp, sieve, pop3 (core dumps disabled)

    Any ideas? google searches are coming up with not a lot of help.

    Reply
    • 2017-01-24 at 15:18
      Permalink

      OK, I seem to be only making matters worse in attempts to resolve this one:

      Jan 24 23:03:27 DamnITMailServer dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
      Jan 24 23:03:27 DamnITMailServer dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
      Jan 24 23:03:27 DamnITMailServer dovecot: config: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
      Jan 24 23:03:27 DamnITMailServer dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
      Jan 24 23:03:27 DamnITMailServer dovecot: master: Dovecot v2.2.13 starting up for imap, lmtp, sieve, pop3 (core dumps disabled)
      Jan 24 23:17:03 DamnITMailServer dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
      Jan 24 23:17:03 DamnITMailServer dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
      Jan 24 23:17:03 DamnITMailServer dovecot: config: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
      Jan 24 23:17:03 DamnITMailServer dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
      Jan 24 23:17:03 DamnITMailServer dovecot: master: Dovecot v2.2.13 starting up for imap, lmtp, sieve, pop3 (core dumps disabled)

      Hope someone will be able to help with this as its the second time I have got it starting the entire server from scratch and not keen on a third time…

      Reply
      • 2017-01-25 at 18:05
        Permalink

        Fresh setup done today from scratch following EVERYTHING to the letter…

        Jan 26 00:05:53 damnmailserver postfix/master[4851]: daemon started — version 2.11.3, configuration /etc/postfix
        Jan 26 00:07:24 damnmailserver spamd[9933]: logger: removing stderr method
        Jan 26 00:07:26 damnmailserver spamd[9935]: spamd: server started on IO::Socket::IP [127.0.0.1]:783, IO::Socket::IP [::1]:783 (running version 3.4.0)
        Jan 26 00:07:26 damnmailserver spamd[9935]: spamd: server pid: 9935
        Jan 26 00:07:26 damnmailserver spamd[9935]: spamd: server successfully spawned child process, pid 9936
        Jan 26 00:07:26 damnmailserver spamd[9935]: spamd: server successfully spawned child process, pid 9937
        Jan 26 00:07:26 damnmailserver spamd[9935]: prefork: child states: IS
        Jan 26 00:07:26 damnmailserver spamd[9935]: prefork: child states: II
        Jan 26 00:07:55 damnmailserver spamass-milter[10693]: spamass-milter 0.3.2 starting
        Jan 26 00:08:37 damnmailserver dovecot: master: Dovecot v2.2.13 starting up without any protocols (core dumps disabled)
        Jan 26 00:08:37 damnmailserver dovecot: ssl-params: Generating SSL parameters
        Jan 26 00:08:40 damnmailserver dovecot: ssl-params: SSL parameters regeneration completed
        Jan 26 00:08:41 damnmailserver dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 00:08:41 damnmailserver dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 00:08:41 damnmailserver dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 00:08:41 damnmailserver dovecot: master: Dovecot v2.2.13 starting up for imap, lmtp, pop3 (core dumps disabled)
        Jan 26 00:08:43 damnmailserver dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 00:08:43 damnmailserver dovecot: anvil: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 00:08:43 damnmailserver dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 00:08:43 damnmailserver dovecot: config: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 00:08:43 damnmailserver dovecot: master: Dovecot v2.2.13 starting up for imap, lmtp, sieve, pop3 (core dumps disabled)
        Jan 26 01:40:42 damnmailserver postfix/postmap[23449]: warning: connect to mysql server 127.0.0.1: Access denied for user ‘mailuser’@’localhost’ (using password: YES)
        Jan 26 01:40:42 damnmailserver postfix/postmap[23449]: fatal: table mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf: query error: Success
        Jan 26 01:46:37 damnmailserver spamass-milter[630]: spamass-milter 0.3.2 starting
        Jan 26 01:46:37 damnmailserver dovecot: master: Error: systemd listens on port 993, but it’s not configured in Dovecot. Closing.
        Jan 26 01:46:37 damnmailserver dovecot: master: Error: systemd listens on port 993, but it’s not configured in Dovecot. Closing.
        Jan 26 01:46:37 damnmailserver dovecot: master: Dovecot v2.2.13 starting up for imap, lmtp, sieve, pop3 (core dumps disabled)
        Jan 26 01:46:39 damnmailserver postfix/master[1273]: daemon started — version 2.11.3, configuration /etc/postfix
        Jan 26 02:02:56 damnmailserver dovecot: config: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 02:02:56 damnmailserver dovecot: log: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)
        Jan 26 02:02:56 damnmailserver dovecot: master: Warning: Killed with signal 15 (by pid=1 uid=0 code=kill)

        Please… WTF is going on here??

        Reply
        • 2017-01-25 at 19:11
          Permalink

          I had that same killed by signal 15 error at one point, i ended up tracking it down to a password thing. look at this file, from the setting up dovecot page. just a guess based on my own experience but:

          /etc/dovecot/dovecot-sql.conf.ext
          check this line
          connect = host=127.0.0.1 dbname=mailserver user=mailuser password=ChangeMe <- use your database access password instead

          be sure you change the ChangeMe to your own password from the step where he has you do the pwgen -s 25 1 and remove the rest of the line. if it's not there, there are several files with the similar ChangeMe, on the preparing the database page, double-check all of those, they should all have the same password, also be sure you didn't include "<- use your database access password instead" in any file.

          Reply
          • 2017-01-26 at 05:51
            Permalink

            checked that all files with user=mailuser had the correct password. One had the password generated for msql instead (doh). but now i dont get the line:

            … dovecot: master: Dovecot v2.2.13 starting up for imap, sieve, pop3 (core dumps disabled)

            All I get now is:

            Jan 26 13:26:38 damnmailserver spamass-milter[642]: spamass-milter 0.3.2 starting
            Jan 26 13:26:40 damnmailserver postfix/master[1272]: daemon started — version 2.11.3, configuration /etc/postfix

            Grr… frustrating. will check over everything again

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close