[2019-11-26]

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”.

21 thoughts on “Testing IMAP

  • 2019-12-29 at 18:17
    Permalink

    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!

    Reply
    • 2019-12-29 at 18:52
      Permalink

      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.

      Reply
  • 2019-12-29 at 19:16
    Permalink

    This is what that code looks like:

    driver = mysql
    connect = host=127.0.0.1 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…

    Reply
    • 2019-12-29 at 19:31
      Permalink

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

      Reply
      • 2019-12-29 at 20:09
        Permalink

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

        Reply
  • 2020-01-02 at 05:14
    Permalink

    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?

    Reply
    • 2020-01-02 at 11:59
      Permalink

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

      {CRAM-MD5}asldfhasdmofuzsapduif…
      {PLAIN-MD5}sapjhapmsdofzuma…
      {SHA256-CRYPT}asöldfimapsdio…
      {BLF-CRYPT}apodisfhpasduio…

      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.

      Reply
  • 2020-01-12 at 01:43
    Permalink

    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)
    http://wiki2.dovecot.org/
    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’.

    Reply
    • 2020-01-14 at 11:58
      Permalink

      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.

      Reply
  • 2020-01-16 at 20:29
    Permalink

    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.

    VG,
    toby

    Reply
    • 2020-01-20 at 12:26
      Permalink

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

      Reply
  • 2020-03-01 at 00:07
    Permalink

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

    Reply
    • 2020-03-01 at 08:54
      Permalink

      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.

      Reply
  • 2020-06-11 at 06:01
    Permalink

    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?

    Reply
    • 2020-06-11 at 06:32
      Permalink

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

      Reply
  • 2020-08-04 at 12:05
    Permalink

    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=192.168.0.1, lip=192.168.0.79

    https part works perfectly – no problems at all…

    Reply
    • 2020-08-04 at 12:37
      Permalink

      Found the problem 🙂 used fullchain.pem twice 🙂

      Reply
  • 2020-09-20 at 19:14
    Permalink

    CORRECTION – I realised my error message runs over two lines:

    Sep 20 18:04:25 raspberrypi dovecot: auth-worker(12830): Error: sql(xxx@xxxonline.com,86.176.xxx.xx,): Invalid password in passdb: Not a valid MD5-CRYPT or PLAIN-MD5 password
    Sep 20 18:04:27 raspberrypi dovecot: imap-login: Disconnected (auth failed, 1 attempts in 6 secs): user=, method=PLAIN, rip=86.176.xxx.xx, lip=192.168.1.xxx, TLS, session=

    Reply
    • 2020-10-05 at 19:32
      Permalink

      How did you create the password?

      Reply
  • 2020-10-04 at 13:48
    Permalink

    Hi Cristoph,
    when i Try to test imaps the request fail:

    pi@hermes:~ $ mutt -f imaps://test@desimoneict.com@webmail.desimoneict.com
    Impossibile connettersi a webmail.desimoneict.com (Chiamata di sistema interrotta).

    pi@hermes:~ $ systemctl status dovecot
    ● dovecot.service – Dovecot IMAP/POP3 email server
    Loaded: loaded (/lib/systemd/system/dovecot.service; enabled; vendor preset: enabled)
    Active: active (running) since Sun 2020-10-04 14:50:10 CEST; 14min ago
    Docs: man:dovecot(1)
    http://wiki2.dovecot.org/
    Main PID: 25250 (dovecot)
    Tasks: 4 (limit: 2065)
    CGroup: /system.slice/dovecot.service
    ├─25250 /usr/sbin/dovecot -F
    ├─25252 dovecot/anvil
    ├─25253 dovecot/log
    └─25254 dovecot/config

    ott 04 14:50:10 hermes systemd[1]: Started Dovecot IMAP/POP3 email server.
    ott 04 14:50:10 hermes dovecot[25250]: master: Dovecot v2.3.4.1 (f79e8e7e4) starting up for imap, lmtp, sieve, pop3 (core dump

    my record mx is “10 hermes.desimoneict.com.”

    when instead I try to connetct to imap:

    mutt -f imap://test@desimoneict.com@webmail.desimoneict.com
    Password per test@desimoneict.com@webmail.desimoneict.com:

    where could I look to solve?

    Reply
    • 2020-10-05 at 14:16
      Permalink

      Maybe you figured it out already? When I run the “mutt” command you mentioned I get a connection.

      Reply

Leave a Reply to toby Cancel reply

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