Install and Configure Dovecot

With Postfix installed, I can now install Dovecot, the Mail Delivery Agent that creates a POP3 and IMAP server, which allows users to download their email from the server.

Install and Test Dovecot

apt-get install dovecot-common

I need to configure Dovecot. There is a section that defines the socket to which to listen: That must be uncommented and updated to identify Postfix as the client.

iwuser$ sudo vi /etc/dovecot/dovecot.conf
socket listen {
   client {
      path = /var/spool/postfix/private/auth-client
      mode = 0660
      user = postfix
      group = postfix
   }
}
sudo /etc/init.d/dovecot restart

Before implementing the POP3 and IMAP servers, I want to test the Postfix installation with telnet.

sudo apt-get install telnet
telnet localhost 25
Trying 127.0.0.1...
Connected to istarel.
Escape character is '^]'.
220 istarel ESMTP Postfix (Ubuntu)
ehlo localhost
250-istarel
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: root@localhost
250 2.1.0 Ok
rcpt to: iwuser@localhost
250 2.1.5 Ok
data
354 End data with .
Subject: Ensuring Postfix is installed correctly

Hi,
This is the test message...
.
250 2.0.0 Ok: queued as 8BCAE3819C
quit
221 2.0.0 Bye
Connection closed by foreign host.
You have new mail in /var/mail/iwuser

Update Postfix with Mailbox Configuration

Dovecot supports the popular maildir format for client mailboxes. The Postfix configuration file must be prepared with this in mind:

sudo postconf -e 'home_mailbox = Maildir/'
sudo postconf -e 'mailbox_command = '

Secure POP3 and IMAP

Dovecot supports four different protocols: POP3, Secure POP3, IMAP, and Secure IMAP. For Istarel Workshop, I am only considering the two secure protocols. The Dovecot configuration must be modified to show which protocols to support, and must be told where the SSL certificates are located (which I created when describing the Postfix installation and configuration).

sudo apt-get install dovecot-imapd dovecot-pop3d
sudo vi /etc/dovecot/dovecot.conf
protocols = pop3s imaps
ssl_disable = no
ssl_cert_file = /etc/ssl/certs/smtpd.crt
ssl_key_file = /etc/ssl/private/smtpd.key
ssl_key_password = secret
disable_plaintext_auth = no
sudo /etc/init.d/postfix restart
sudo /etc/init.d/dovecot restart

Email clients should now be able to connect via POP3 and IMAP to check and manage email.

There is only one housekeeping task left to perform: Though telnet is a convenient tool to verify a working implementation of Postfix and Dovecot, it is also horribly insecure, so I will remove it from the server.

sudo aptitude remove telnet