How to configure IMAP with SSL

IMAP or Internet Message Access Protocol is one of the two most commonly used protocols for e-mail retrieval. This is a step-by-step tutorial on how to configure IMAP to use SSL encryption for secure communication on port 993 (by default IMAP uses port 143).

Install Dovecot and OpenSSL packages using the following command:

yum -y install dovecot openssl

Edit the dovecot-openssl.cnf configuration file:

vi /etc/pki/dovecot/dovecot-openssl.cnf
[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no

[ req_dn ]
# country (2 letter code)

# State or Province Name (full name)

# Locality Name (eg. city)

# Organization (eg. company)
O=<your company name>

# Organizational Unit Name (eg. section)
OU=<your company section name>

# Common Name (* is also possible)

# E-mail contact

[ cert_type ]
 nsCertType = server

Edit the main Dovecot configuration file:

vi /etc/dovecot.conf

Find and uncomment the following lines:

protocols = imap imaps

ssl_disable = no

ssl_cert_file = /etc/pki/dovecot/certs/dovecot.pem

ssl_key_file = /etc/pki/dovecot/private/dovecot.pem

Execute the following command to delete the existing certificate files:

rm -rf /etc/pki/dovecot/{certs,private}/dovecot.pem

Create new dovecot.pem certificates using the ‘’ script:


Restart the Dovecot service for the changes to take effect:

/etc/init.d/dovecot restart

Then, test if everything is set up properly using the Mutt text email client:

mutt -f imap://
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
How to install Magento on a Linux Virtual Server
Install Orangescrum on an Ubuntu 16.04 VPS
Install, configure and administer BIND 9 on Debian Whezzy
There are currently no comments.