The Courier package contains a Mail Transport Agent (MTA). This is useful for sending email to other users of your host machine. It can also be configured to be a central mail server for your domain or a mail relay agent. The Courier packages also includes a web-based email interface, IMAP, IMAP-SSL, POP3, and POP3-SSL.
Download (HTTP): http://prdownloads.sourceforge.net/courier/courier-0.45.5.tar.bz2
Download size: 4.2 MB
Estimated Disk space required: 114 MB
Estimated build time: 3.00 SBU
Before you compile the program, you need to create users and groups that will be expected to be in place when the install script executes. Add the users and groups with the following commands:
groupadd courier &&
useradd -c 'Courier Mail Server' -d /dev/null -g courier -s /bin/false courier
You also need to create a bin user. If you already have a user named bin, this step can be safely ignored.
useradd -c 'bin' -d /dev/null -g bin -u 1 bin
This creates a /var/run/courier directory where all the Courier MTA pid files will exist. This will allow courierfilter.pid to be created. Without the courierfilter running, the Courier MTA will not work. Issue the following commands to create /var/run/courier:
mkdir /var/run/courier &&
chown courier:courier /var/run/courier
Install courier by running the following commands:
./configure --prefix=/usr --libexecdir=/usr/lib/courier \
--datadir=/usr/share/courier --sysconfdir=/etc/courier \
--localstatedir=/var/lib/courier --with-piddir=/var/run/courier \
--disable-root-check --with-mailuser=courier --with-mailgroup=courier \
--with-paranoid-smtpext --disable-autorenamesent \
--enable-workarounds-for-imap-client-bugs --with-db=gdbm &&
make &&
make install &&
make install-configure
--libexecdir=/usr/lib/courier: Specifies the directory which contains programs and libraries that cannot be directly executed from the command-line.
--datadir=/usr/share/courier: Specifies the directory where miscellaneous shell scripts, Perl scripts, and data files will be installed.
--localstatedir=/var/spool/courier: Specifies the directory that will hold the mail queue, and other temporary data.
--with-piddir=/var/run/courier: Specifies the directory where Courier's PID files are stored when Courier is active.
--disable-root-check: Allows Courier to be built as the root user.
--with-mailuser=courier: All except two Courier daemons run as a non-privileged user. This option specifies the userid that Courier will install and run as.
--with-mailgroup=courier: like --with-mailuser, but specifies the group ID.
--with-paranoid-smtpext: Be paranoid when negotiating Courier-specific ESMTP extensions with remote servers. The Courier mail server defines and implements certain experimental ESMTP extensions: XVERP and XEXDATA. Problems may result in the event that someone else uses the same name to implement some other extension. If this option is specified, Courier's ESMTP server will also advertise a dummy ESMTP capability called XCOURIEREXTENSIONS, and will not recognize any Courier-specific extensions unless the remote mail server also advertises this dummy ESMTP capability.
--disable-autorenamesent: Do not rename the Sent folder every month. This option can also be controlled by the SQWEBMAIL_AUTORENAMESENT environment variable.
--enable-workarounds-for-imap-client-bugs: There are several confirmed bugs in some IMAP clients that do not properly implement the IMAP4rev1 protocol. This option enables some workarounds for those buggy IMAP clients. NOTE: make check will fail if this option is used. You should first configure without this option, and if all post-configuration tests succeed, rerun configure with this option and recompile.
--with-db=gdbm: Courier requires either the GDBM or the DB database library. GDBM is used if both are present. This option forces the selection of the GDBM database library since support for DB is broken at the current state.
--with-ispell=/usr/bin/aspell: Courier's webmail server can use spell checking, if configure finds ispell or if you explicitly set the location of aspell.
--enable-mimetypes=[location of mime.types file]: Use this switch if you receive an error saying that the mime.types file could not be found.
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 (
'[email protected]',
'',
'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
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-0.45.5/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
The Courier package contains addcr, authenumerate, cancelmsg, courier, courier-config, courieresmtpd, courierfilter, courierldapaliasd, courierlogger, couriermlm, couriertcpd, couriertls, deliverquota, dotforward, esmtpd, esmtpd-msa, esmtpd-ssl, filterctl, imapd, imapd, imapd-ssl, lockmail, mailbot, maildiracl, maildirkw, maildirmake, maildrop, makeacceptmailfor, makealiases, makedat, makehosteddomains, makemime, makepercentrelay, makesmtpaccess, makesmtpaccess-msa, makeuserdb, makeuucpneighbors, mimegpg, mkesmtpdcert, mkimapdcert, mkpop3dcert, pop3d, pop3d-ssl, preline, pw2userdb, reformail, reformime, rmail, sendmail, sharedindexinstall, sharedindexsplit, showconfig, showmodules, testmxlookup, userdb, userdbpw, vchkpw2userdb and webgpg.
courier is a modular multi-protocol E-mail transport agent. The courier command is an administrative command, and most of its options are only available to the superuser.
courierfilter command installs or uninstalls global mail filters. Global mail filters are used to selectively block unwanted mail.
filterctl command installs or uninstalls global mail filters. Global mail filters are used to selectively block unwanted mail.
mailbot reads an E-mail message on standard input and creates an E-mail message replying to the original message's sender.
maildrop is a replacement local mail delivery agent that includes a mail filtering language.
makeacceptmailfor Build a list of domains to accept mail for from the /etc/courier/esmtpacceptmailfor.dir directory.
makealiases Build a list of aliases from the /etc/courier/aliases or /etc/courier/aliasdir directories.
makepercentrelay Build a list of %-relayed domains from the percentrelay.dir directory.
makesmtpaccess Build ESMTP server access file from the /etc/courier/smtpaccess directory.
makesmtpaccess-msa Build ESMTP server access file from the /etc/courier/smtpaccess directory. This esmtp list is for the MSA protocol.
makeuucpneighbors Builds a list of UUCP recipients using /etc/courier/uucpneighbors.
reformail program reads a message on standard input, reformats it in some way, and writes the message to standard output.
sendmail command reads an E-mail message and delivers the message to its recipients. This sendmail command is part of the Courier mail server, although it attempts to emulate the behavior of the original sendmail MTA.