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) C=<your_country_code> # State or Province Name (full name) ST=<state> # Locality Name (eg. city) L=<your_city> # Organization (eg. company) O=<your company name> # Organizational Unit Name (eg. section) OU=<your company section name> # Common Name (*.example.com is also possible) CN=www.yourdomain.com # E-mail contact emailAddress=info@yourdomain.com [ 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 ‘mkcert.sh’ script:
/usr/share/doc/dovecot-1.0.7/examples/mkcert.sh
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://username@yourdomain.com/
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.