Configuring <application>Courier</application> Config files /etc/courier/* Configuration Information Make the following changes in /etc/courier/authmysqlrc file if you are utilizing MySQL: MYSQL_SERVER localhost MYSQL_USERNAME courier MYSQL_PASSWORD [your choice] MYSQL_SOCKET /tmp/mysql.sock MYSQL_PORT 3306 MYSQL_DATABASE courier_mail MYSQL_USER_TABLE users MYSQL_CLEAR_PWFIELD clear DEFAULT DOMAIN [your domain] MYSQL_QUOTA_FIELD quota If you utilize PAM: cat > /etc/pam.d/esmtp << "EOF # Begin /etc/pam.d/esmtp auth required pam_unix.so try_first_pass account required pam_unix.so session required pam_unix.so # End /etc/pam.d/esmtp EOF cat > /etc/pam.d/pop3 << "EOF # Begin /etc/pam.d/pop3 auth required pam_unix.so try_first_pass account required pam_unix.so session required pam_unix.so # End /etc/pam.d/pop3 EOF cat > /etc/pam.d/imap << "EOF # Begin /etc/pam.d/imap auth required pam_unix.so try_first_pass account required pam_unix.so session required pam_unix.so # End /etc/pam.d/imap EOF cat > /etc/pam.d/webmail << "EOF # Begin /etc/pam.d/webmail auth required pam_unix.so try_first_pass account required pam_unix.so session required pam_unix.so # End /etc/pam.d/webmail EOF Connect to the MySQL database: mysql -p This command will create the database for authentication: CREATE DATABASE courier_mail; USE courier_mail This command will setup the table users for the courier_mail database: CREATE TABLE users ( id char(128) DEFAULT '' NOT NULL, crypt char(128) DEFAULT '' NOT NULL, clear char(128) DEFAULT '' NOT NULL, name char(128) DEFAULT '' NOT NULL, uid int(10) unsigned DEFAULT '65534' NOT NULL, gid int(10) unsigned DEFAULT '65534' NOT NULL, home char(255) DEFAULT '' NOT NULL, quota char(255) DEFAULT '' NOT NULL, KEY id (id(128)) ); This will add the courier user that we specified earlier in the /etc/courier/authmysqlrc file: GRANT ALL PRIVILEGES ON *.* TO courier@localhost IDENTIFIED BY '[password]' WITH GRANT OPTION; QUIT General Settings for Mail You will need to create the following files with the contents specified. /etc/courier/defaultdomain cat > /etc/courier/defaultdomain << "EOF" [yourdomain] EOF /etc/courier/me cat > /etc/courier/me << "EOF" [servername.yourdomain] EOF /etc/courier/locals cat > /etc/courier/locals << "EOF" localhost [yourdomain] EOF /etc/courier/esmtpacceptmailfor.dir/system cat >/etc/courier/esmtpacceptmailfor.dir/system << "EOF" localhost [yourdomain] EOF You will also need to edit the aliases file and change the following entry. /etc/courier/aliases/system postmaster: [your administrator email] If you want to deny access from some hosts from sending mail, you will need to edit the /etc/courier/smtpaccess/default file. After the above steps are completed you will need to run the following commands: makesmtpaccess && makehosteddomains && makealiases SMTP/SMTMP-SSL Configuration This section will enable the SMTP Server from Courier /etc/courier/esmtpd ESMTPDSTART=YES /etc/courier/esmtpd-ssl ESMTPDSSLSTART=YES POP3/POP3-SSL Configuration This section will enable the POP3 Server from Courier /etc/courier/pop3d POP3DSTART=YES /etc/courier/pop3d-ssl POP3DSLLSTART=YES IMAP/IMAP-SSL Configuration This section will enable the IMAP Server from Courier /etc/courier/imapd IMAPDSTART=YES /etc/courierd/imapd-ssl IMAPDSSLSTART=YES Creating Mail directories for System Users This section will explain how to create MailDirs for your system users. cd /home/[username] && maildirmake Maildir && chown [username].[username] Maildir -R Setup for Virtual users This section will explain how to setup Maildir for your virtual users. groupadd -g 9000 vmailman && useradd -c 'Virtual Mailman' -g vmailman -m -k /dev/null -u 9000 vmailman Now to setup the Maildir for these virtual users. cd /home/vmailman && mkdir [virtual_user] && cd [virtual_user] && maildirmake Maildir && chown vmailman.vmailman Maildir -R Connect to the MySQL database. mysql -u courier -p To add the virtual user you need to enter at least one version of the password either clear text or encrypted. USE courier_mail INSERT INTO users VALUES ( '[virtual_users]@[domain.com], '[encrypted password or blank]', '[clear text password or blank]', '[User's Name]', 9000, 9000, '[location of Maildir]', '[Quota in Bytes'] ); QUIT For example: INSERT INTO users VALUES ( 'blfsuser@linuxfromscratch.org', '', 'password', 'BLFS User', 9000, 9000, '/home/vmailman/blfsuser', '' ); Setup for Web-based Email This section will explain how to setup Courier Web-based email system. You will need to copy the webmail file from /usr/lib/courier/courier/webmail to your cgi-bin directory of your Apache server. cp -a /usr/lib/courier/courier/webmail/webmail /var/www/cgi-bin You will then need to copy the images to a directory under your htdocs directory of your Apache server. The directory needs to be named webmail or you need to specify it during the configure phase with --enable-imageurl=[URL]. cp -a /usr/share/courier/sqwebmail/images /var/www/htdocs/webmail Setup for Web-based Email This section will explain how to setup Courier Web-based administration system. You will need to copy the webadmin file from /usr/lib/courier/courier/webmail to your cgi-bin directory of your Apache server. cp -a /usr/lib/courier/courier/webmail/webadmin /var/www/cgi-bin /etc/courier/webadmin/password cat > /etc/courier/webadmin/password << "EOF" [password] EOF If you are not using SSL on your Apache server, you will need to add /etc/courier/webadmin/unsecureok, so you will be able to use your web based administration tool. touch /etc/courier/webadmin/unsecureok Courier init.d script The startup script from the Courier package is the easiest to use. It will automatically create missing data files, and SSL certificates if they are missing. To install the init.d file for Courier, you will need to use the following commands: cp /usr/src/courier-&courier-version;/courier.sysvinit /etc/rc.d/init.d/courier && chmod 754 /etc/rc.d/init.d/courier Create the symbolic links to this file in the relevant rc.d directory with the following commands: cd /etc/rc.d/init.d && ln -sf ../init.d/courier ../rc0.d/K25courier && ln -sf ../init.d/courier ../rc1.d/K25courier && ln -sf ../init.d/courier ../rc2.d/K25courier && ln -sf ../init.d/courier ../rc3.d/S35courier && ln -sf ../init.d/courier ../rc4.d/S35courier && ln -sf ../init.d/courier ../rc5.d/S35courier && ln -sf ../init.d/courier ../rc6.d/K25courier