Installation of the IMAP server
Let’s begin with :
apt-get install courier-imap
Now courier-imap will be configurable into the /etc/courier/imapd file. There you can specify the port to use or the name of the path you want to use for the mail. By default the mail directory is called “Maildir” (you can modify it with the parameter MAILPATH=~/Maildir or MAILDIRPATH). To configure it for an user, go into the directory with the same privilege than the user :
cd /home/user
sudo -s -u user
maildirmake Maildir
Installation of the SMTP server
For postfix it’s quite simple, there is a user-friendly interface helping us to configure it :
sudo dpkg-reconfigure postfix
Choose the internet server :

Add the domain-name of your network (the same than for the DNS server)

In our case, don’t use procmail, we don’t need to have an anti-spam engine or so, so just reply no to the question.

For a local network is IPv4 more than enough.

Now we just need to add one line into the postfix configuration file /etc/postfix/main.cf to specify the user mail directory :
home_mailbox = ~/Maildir/
Test the mail server
First reload the server to enable the last modification of the configuration.
sudo /etc/init.d/postfix restart && sudo /etc/init.d/courier-imap restart && sudo /etc/init.d/courier-authdaemon restart
Install the tools we’ll need :
sudo apt-get install mailutils
Let’s send a mail to an existing user :
# mail user@knowledgeplaza.lan
Subject: this is a test message
hello foo bar
.
Cc:
To quit the body of the mail you can do “CTRL+d” or add a “.” in an empty line.
Let’s check if the mail was correctly recieved :
ls /home/user/Maildir/new/
It should work.
Configure your favorite mail client
First we need to startup qemu with the right ports open. Otherwise it’ll be impossible to reach the virtual server. So add to que qemo command -redir tcp:5525::25 and -redir tcp:5514::143. Once done, go into your favorite mail client and create a new account with the following parameters :
- Email address : user@knowledgeplaza.lan (with your own hostname of course)
- IMAP server : 127.0.0.1
- IMAP port : 5514
- SMTP server : 127.0.0.1
- SMTP port : 5525
- Login : user
- Password : user unix password
Now it should work for the configured user.
More references: