Wednesday, 22 April 2015

POP, IMAP using Dovecot in RHEL7

POP and IMAP are 2 protocols to retrieve mail from a mail server.

POP is best for users who have one system on which to read email. Email clients generally delete messages from the server, after downloading. However, this setting can be changed. Also, the entire content of each message is downloaded.

IMAP is best for users who access their email using multiple machines. Email messages remain on the server, where users can read or delete them. IMAP also allows client apps to create mail dir(s) on the server. Also, only email header information is downloaded for messages, until opened.

Follow the following steps:

1) Install packages
     yum -y install dovecot
     yum -y install mutt

2) Edit the file '/etc/dovecot/dovecot.conf' and make the following changes.
     protocols = imap pop3 

3) Edit the file '/etc/dovecot/conf.d/10-mail.conf' and make the following changes.
     mail_location = mbox:~/mail:INBOX=/var/mail/%u

4) Edit the file '/etc/dovecot/conf.d/10-auth.conf' and make the following changes.
     auth_mechanisms = plain login

5) Change permission for mail spool file.
     cd /var/spool/mail
     chmod 600 *

6) Create new Dovecot self-signed certificate (Optional)  
    6.1)Edit the file '/etc/pki/dovecot/dovecot-openssl.cnf' and enter server hostname and other details.

    6.2)Delete default certificate and private key
           rm /etc/pki/dovecot/private/dovecot.pem
           rm /etc/pki/dovecot/certs/dovecot.pem

    6.3)Run the following script to generate new certificate.

    6.4)Edit in file '/etc/dovecot/conf.d/10-ssl.conf'
           ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
           ssl_key = </etc/pki/dovecot/private/dovecot.pem

7) Verify parameters changed in config files.
        doveconf  -n 

8) Start the service.
      systemctl start dovecot     
      systemctl enable dovecot

9) Open Firewall ports.(POP3-110/tcp,IMAP-143/tcp, POP3S-995/tcp, IMAPS-993/tcp)
      firewall-cmd --zone=public --add-service=pop3s --permanent
      firewall-cmd --zone=public --add-service=imaps --permanent
      firewall-cmd --zone=public --add-port=110/tcp --permanent
      firewall-cmd --zone=public --add-port=143/tcp --permanent

10) Check the connection
      mutt -f pops://

1 comment: