For now, our server can receive emails, but we have no way of accessing those emails from a mail client. For this we are going to use Courier as our IMAP and POP server.
Dovecot is another popular option, but for
  this integration you will have to look elsewhere. For me, Dovecot is not an
  option because it does not automatically check for new mail in all of the
  IMAP folder when you select Get Mail option in your mail
  client. And since all of the emails marked as Spam is
  moved automatically to a Junk folder my client would
  not report to me if there are any new messages in the
  Junk folder unless I explicitly check for them.
apt-get install courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl fam
If you do not want to use POP you can skip installing packages that provide POP and install only
apt-get install courier-authdaemon courier-authlib-mysql courier-imap courier-imap-ssl fam
When asked if you would like to create directories for web-based
    administration, answer No.
Open /etc/courier/authdaemonrc and
    change
authmodulelist="authpam"
to
authmodulelist="authmysql"
Empty /etc/courier/authmysqlrc and paste the
    following (change you password).
MYSQL_SERVER localhost
MYSQL_USERNAME mailadmin
MYSQL_PASSWORD newpassword
MYSQL_PORT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(username,'@',-1),'/',SUBSTRING_INDEX(username,'@',1),'/')
MYSQL_QUOTA_FIELD concat(quota,'S')
    Notice that the QUOTE_FIELD has an “S” appended to the value. This is because Postfix Admin stores MailDir quota as an integer, and Courier maildrop expects the quota value to be in the format XXXS, where XXX represent the number of bytes that can be stored in the Maildir, and “S” stands for size.
Maildrop can also use XXXC, where “C” I guess stands for “COUNT” because this value stands for number of messages that MailDir can store.