Follow these steps to enable IMAP and POP3 with Dovecot
Step 1 : First, install the Dovecot binaries from the Ubuntu main repository:
Step 2 : Next, proceed with configuring Dovecot. Open the file /etc/dovecot/dovecot.conf. By default Dovecot has enabled POP3 and IMAP protocols in main configuration file.
Step 3 : Open /etc/dovecot/conf.d/10-mail.conf and set the mailbox to be used. Dovecot supports mbox as well as Maildir. Make sure you set the correct path of your mail directory:
Step 4 : Open /etc/dovecot/conf.d/10-ssl.conf and uncomment or change the following lines to enable SSL authentication.
Step 5 : Restart the Dovecot daemon
Step 6 : Test Dovecot by creating a telnet connection. You should see an output similar to the following: