Next, we'll set up IMAP on the mailserver. We already installed the packages for Courier IMAP in the previous chapter, so we don't need to start up the temporary connection to the internet again.
As with the previous chapter, the material for setting up Courier IMAP is mostly based on [ArchLinuxPostfix10]
First, edit /etc/courier-imap/imapd. Set the ADDRESS line to:
ADDRESS=0
This tells Courier to listen on all interfaces. We will be listening on the loopback interface (for running webmail) and also on the network interface.
Next, edit /etc/authlib/authdaemonrc. Find the line beginning with authmodulelist and delete it. Replace it with:
authmodulelist="authmysql"
Next, delete the default /etc/authlib/authmysqlrc and create a file with the following:
MYSQL_SERVER localhost MYSQL_USERNAME postfixuser MYSQL_PASSWORD postfixpassword MYSQL_SOCKET /var/run/mysqld/mysqld.sock MYSQL_DATABASE postfix MYSQL_USER_TABLE users MYSQL_CLEAR_PWFIELD password MYSQL_UID_FIELD '5003' MYSQL_GID_FIELD '5003' MYSQL_LOGIN_FIELD email MYSQL_HOME_FIELD "/home/vmailer" MYSQL_MAILDIR_FIELD concat(domain,'/',email,'/') MYSQL_QUOTA_FIELD quota
Note the use of "postfixpassword" as the password; this is the password to the MySQL database, so in real life it would be something more secure.
Next, edit /etc/hosts.allow and add the following:
sunrpc:localhost 127.0.
Next, edit /etc/fam/fam.conf and add/change the following:
local_only = true idle_timeout = 0
Next, edit /etc/rc.conf and add rpcbind fam authdaemond courier-imap after postfix but before httpd
Go to the gateway.isp.sam VM. Add the following to /etc/dhcpd.conf in the subnet 172.16.152.0 section:
host static-client {
hardware ethernet xx:xx:xx:xx:xx:xx;
fixed-address 172.16.152.15;
}Set the ethernet address to the actual ethernet address of mail.isp.sam. Kill the dhcpd process and restart it.
Go back to mail.isp.sam, and start up the required processes:
sudo /etc/rc.d/rpcbind start
sudo /etc/rc.d/fam start
sudo /etc/rc.d/authdaemond start
sudo /etc/rc.d/courier-imap start
Test the IMAP server:
telnet 172.16.152.15 imap
Trying 172.16.152.15... Connected to 172.16.152.15. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2010 Double Precision, Inc. See COPYING for distribution information.
A LOGIN "sam@isp.sam" "sampassword"
A OK LOGIN Ok.
B SELECT "Inbox"
* FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent) * OK [PERMANENTFLAGS (\* \Draft \Answered \Flagged \Deleted \Seen)] Limited * 3 EXISTS * 3 RECENT * OK [UIDVALIDITY 1290482568] Ok * OK [MYRIGHTS "acdilrsw"] ACL B OK [READ-WRITE] Ok
Z LOGOUT
* BYE Courier-IMAP server shutting down Z OK LOGOUT completed
If that worked, then the IMAP server is working. Repeat the above steps from the customer VM:
telnet mail.isp.sam imap
That should give the same results as the local attempt.