Testing IMAP

You have already finished the configuration of Dovecot so fetching emails using the IMAP protocol will already work. Let’s give it a try using a simple but powerful IMAP client: mutt.

mutt -f imaps://john@example.org@webmail.example.org

The connection URL may look a little confusing because of the two “@” characters. Usually mutt expects the format imaps://user@server. And as we use the email address as the “user” part you get this look.

You should get prompted for the password which is “summersun”. If you get any certificate warnings then check if you used the correct server name to connect to and if you finished the certificate/LetsEncrypt part earlier in this guide.

After logging in you will see an empty inbox:

Very good – so IMAP connections and authentication works. Exit mutt by pressing “q”.

17 thoughts on “Testing IMAP

  • 2019-12-29 at 18:17

    Struggling here… Everything works flawlessly up to this point with a fresh install. IMAP is failing with the following error when I input the mutt command:

    (ran “systemctl status dovecot” to see this)
    Dec 29 10:48:31 webmail systemd[1]: Started Dovecot IMAP/POP3 email server.
    Dec 29 10:48:31 webmail dovecot[1632]: master: Dovecot v2.3.4.1 (f79e8e7e4) starting up for imap, lmtp, sieve, pop3 (core dump
    Dec 29 10:50:07 webmail dovecot[1636]: auth: Fatal: sqlpool: Missing value in connect string: password
    Dec 29 10:50:07 webmail dovecot[1632]: master: Error: service(auth): command startup failed, throttling for 2 secs
    Dec 29 10:50:07 webmail dovecot[1636]: imap-login: Disconnected: Auth process broken (disconnected before auth was ready, wait
    Dec 29 10:50:07 webmail dovecot[1636]: imap-login: Warning: Timeout leak: 0x7f699e0c9140 (auth-server-connection.c:397)

    It is looking for a password. I’ve been back through everything up to this point and don’t find any coding errors. I also didn’t find any code to set up the IMAP protocol. What am I missing? Thanks!

    • 2019-12-29 at 18:52

      Please take a look at /etc/dovecot/dovecot-sql.conf.ext and check if you defined the password for the “mailserver” user in the “connect” line.

  • 2019-12-29 at 19:16

    This is what that code looks like:

    driver = mysql
    connect = host= dbname=mailserver user=mailserver password = (my password for mailserver)
    user_query = SELECT email as user, \
    concat(‘*:bytes=’, quota) AS quota_rule, \
    ‘/var/vmail/%d/%n’ AS home, \
    5000 AS uid, 5000 AS gid \
    FROM virtual_users WHERE email=’%u’;
    password_query = SELECT password FROM virtual_users WHERE email=’%u’;

    I deleted my actual password for sane reasons, but did verify that it was correct…

    • 2019-12-29 at 19:31

      nevermind. Found it. I had a space before and after the “=” for the password. I believe your code has them also in this guide…

      • 2019-12-29 at 20:09

        Right, the space must not be there. Typo fixed.

  • 2020-01-02 at 05:14

    I see my current mail server has default_pass_scheme = SHA512
    This IMAP test only succeeds If i add that to dovecot-sql.conf.ext.

    Other than having all my users reset their passwords, am I safe to just leave this scheme as-is? Also, do i need to make changes elsewhere to ensure all future accounts have a consistent password scheme?

    • 2020-01-02 at 11:59

      You can make the encryption scheme explicit per user. Just add the scheme to the beginning of the password. Examples:


      That way no matter what you set as “default_pass_scheme” Dovecot will always now how to check the password against the hash with the right algorithm.

  • 2020-01-12 at 01:43

    root@server:/var/www# systemctl status dovecot
    ● dovecot.service – Dovecot IMAP/POP3 email server
    Loaded: loaded (/lib/systemd/system/dovecot.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Sun 2020-01-12 02:39:13 CET; 3min 24s ago
    Docs: man:dovecot(1)
    Process: 27763 ExecStart=/usr/sbin/dovecot -F (code=exited, status=89)
    Main PID: 27763 (code=exited, status=89)

    Jan 12 02:39:13 ispmail systemd[1]: Started Dovecot IMAP/POP3 email server.
    Jan 12 02:39:13 ispmail dovecot[27763]: doveconf: Fatal: Error in configuration file /etc/dovecot/conf.d/15-mailboxes.conf line 45: Unknown setting: mailbox { mailbox
    Jan 12 02:39:13 ispmail dovecot[27763]: doveconf: Error: managesieve-login: dump-capability process returned 89
    Jan 12 02:39:13 ispmail dovecot[27763]: doveconf: Fatal: Error in configuration file /etc/dovecot/conf.d/15-mailboxes.conf line 45: Unknown setting: mailbox { mailbox
    Jan 12 02:39:13 ispmail systemd[1]: dovecot.service: Main process exited, code=exited, status=89/n/a
    Jan 12 02:39:13 ispmail systemd[1]: dovecot.service: Failed with result ‘exit-code’.

    • 2020-01-14 at 11:58

      See the /usr/share/dovecot/conf.d/15-mailboxes.conf file on your disk. That’s the original version. Maybe you can spot where your config has an error.

  • 2020-01-16 at 20:29

    Hallo Christoph,

    mutt -f imaps://xxx@attinetworks.de@webmail.attinetworks.de
    Kann keine Verbindung zu webmail.attinetworks.de aufbauen (Unterbrechung während des Betriebssystemaufrufs).

    Was könnte diese Fehlermeldung bedeuten? Bin Deinem Tutorial bis hierhin minutiös gefolgt.


    • 2020-01-20 at 12:26

      Moin Toby. Hast du das Problem immer noch? Von mir aus klappt das nämlich.

  • 2020-03-01 at 00:07

    I don’t know why. Email are received only maybe 10 min after sending and some email are just not incoming.

    • 2020-03-01 at 08:54

      Well that’s ok. I just realized I had a DNS misconfiguration. Well I had MX record redirect to mail.domain.ltd. but as following this guide, it may have better being webmail.domain.ltd.

      After that change email are welcome and incoming correctly.

  • 2020-06-11 at 06:01

    I am getting an connection refused error when I run mutt -f imaps://john@example.org@webmail.example.org (modified to point to my mail server FQDN).

    Where should I start looking for why that is happening?

    • 2020-06-11 at 06:32

      Found it. I had forgotten to forward the relevant ports on the router. Too early in the day with too little tea!

  • 2020-08-04 at 12:05

    Hello Christoph,

    Thank you very much for amazing instructions.
    Could you please help me as I faced error which I can not fix.
    When I try mutt it fails and dovecot reports back:
    imap-login: Error: Failed to initialize SSL server context: Couldn’t parse private SSL server context: Couldn’t parse private SSL key: error:0909006C:PEM routines:get_name:no start line: Expecting: ANY PRIVATE KEY: user=, rip=, lip=

    https part works perfectly – no problems at all…

    • 2020-08-04 at 12:37

      Found the problem 🙂 used fullchain.pem twice 🙂


Leave a Reply

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