Tuesday, February 15, 2011

Dovecot IMAP Server

The Internet Message Access Protocol (IMAP) is one of the two most prevalent Internet standard protocols for e-mail retrieval. Dovecot is an open source IMAP.
  • IMAP host FQDN: mail1.dev.local, ip: 192.168.10.11, DNS alias: mail.dev.local
  • Mailbox type: Maildir
  • Mail location: /var/mail/<user>
  • Communication: Only secure, TLS/SSL

Basic Installation

Here are few simple steps to configure: Let install dovecot:
apt-get -y install dovecot-imapd

Dovecot V1.x Configuration

Ensure imaps in the following configuration (file /etc/dovecot/dovecot.conf):
protocols = imap imaps
mail_location = maildir:/var/mail/%u

Dovecot V2.0 Configuration

Setup mail location (file /etc/dovecot/conf.d/10-mail.conf)
mail_location = maildir:/var/mail/%u

SSL

  1. Create SSL certificate (see here). While answering questions make sure the following (this is the name the clients will access your IMAP server):
    Common Name (eg, YOUR name) []:mail.dev.local
    
    There are two important files we created here: newreq.pem and newcert.pem. Rename those files:
    mv newreq.pem mail-key.pem
    mv newcert.pem mail-cert.pem
    
  2. Copy these files:
    cp mail-cert.pem /etc/ssl/certs
    cp mail-key.pem /etc/ssl/private
    
  3. Dovecot V1.x Configuration

    Let dovecot know about our certificates (file /etc/dovecot/dovecot.conf):
    ssl_cert_file = /etc/ssl/certs/mail-cert.pem
    ssl_key_file = /etc/ssl/private/mail-key.pem
    

    Dovecot V2.0 Configuration

    Let dovecot know about our certificates (file /etc/dovecot/conf.d/10-ssl.conf):
    ssl_cert = </etc/ssl/certs/mail-cert.pem
    ssl_key = </etc/ssl/private/mail-key.pem
    
  4. Restart dovecot:
    /etc/init.d/dovecot restart
    
You should be able access the mail via IMAP TLS/SSL now. See here how to get rid of warning message about the SSL certificate signature by mail clients, e.g. Evolution, etc.

Troubleshooting: namespace missing

While upgrading to dovecot v2.1.7 I noticed the following error:
mail1 dovecot: imap(xxx): Error: user xxx: Initialization failed: 
namespace configuration error: inbox=yes namespace missing
mail1 dovecot: imap(xxx): Error: Invalid user settings. Refer to 
server log for more information.
You need define inbox namespace and explicitly set the `inbox` attribute (file /etc/dovecot/conf.d/10-mail.conf)
namespace inbox {
    inbox = yes
}
Restart dovecot and that fix it.

2 comments :