Easiest way to set up an IMAP mail server
You can use Dovecot for mail server
-
Install the packages
sudo apt-get install dovecot-imapd dovecot-pop3d
-
Configure the protocol you need to be used by appending the protocol in the file
/etc/dovecot/dovecot.conf
:protocols = pop3 pop3s imap imaps
-
Choose the mailbox you would like to use. Dovecot supports
maildir
andmbox
formats. Edit the file/etc/dovecot/dovecot.conf
and change the linemail_location = maildir:~/Maildir # (for maildir)
or
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u # (for mbox)
-
Restart the service
sudo /etc/init.d/dovecot restart
-
Use telnet to check that dovecot is working properly.
telnet localhost imap
That's it.
PS. Also make sure your firewall is configured properly to accept connections on the appropriate ports.
Source : Official Dovecot Server Documentation