Courier-0.47

Introduction to Courier

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.

Package information

Installation of Courier

[Note]

Note

Courier's tarball must be extacted as an unprivileged user or the configure script will fail.

Before you compile the program, you need to create the courier user and group that is expected to be in place when the install script executes. As the root user, add the courier user and group with the following commands:

groupadd courier &&
useradd -c 'Courier Mail Server' -d /dev/null \
        -g courier -s /bin/false courier

The install script also expects 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

Courierfilter requires the directory /var/run/courier to store all the Courier pid and lockfiles. /var/lock/subsys also must exist for the master lock file for Courier. Issue the following commands to create these directories:

install -d /var/run/courier -o courier -g courier -m755 &&
install -d /var/lock/subsys -o root -g root -m755

Build Courier as an unprivileged user with 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 \
    --with-paranoid-smtpext --disable-autorenamesent \
    --enable-workarounds-for-imap-client-bugs --with-db=gdbm &&
make

Once again, become the root user and install Courier with the following commands:

make install &&
make install-configure

Command explanations

--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.

--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 GDBM as courier is currently broken when used with DB.

--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.

Configuring Courier

Configuration Files

/etc/courier/*

Configuration Information

While still as root, 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 /etc/courier/aliases/system file and change the following entry.

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.

If you wish to host mail for non local domains including virtual domains, you must add them to /etc/courier/hosteddomains. This file should exist whether you need a hosted domain list or not:

touch /etc/courier/hosteddomains

After the above steps are completed you will need to run the following commands:

makesmtpaccess &&
makehosteddomains &&
makealiases

For each user, you will need to create a Maildir directory:

cd /home/[username] &&
maildirmake Maildir &&
chown [username].[username] Maildir -R

If you wish to use SSL with Courier, you should obtain certificates and store them in /usr/share/courier. You can optionally create self-signed, test certificates with the following commands:

mkesmtpdcert &&
mkimapdcert &&
mkpop3dcert

All of Courier's configuration files reside in the directory /etc/courier/. For each service SMTP, POP3 and IMAP, you will have a standard config file, and an SSL config file. For each service that you wish to utilize, you will need to edit the configuration file, and change the [DAEMON]START variable from 'NO' to 'YES'. For example, to use SMTP with SSL, you'll need to edit /etc/courier/esmtpd-ssl and change the value of 'ESMTPDSSLSTART' to 'YES'. Make the same change for each service configuration that you wish to use with Courier.

If you wish to use LDAP, an LDAP configuration file should be created:

echo "LDAPALIASDSTART=YES" > /etc/courier/ldapaliasd

Similarly, if you wish to use webmail, you should create the webmail configuration file:

echo "WEBMAILDSTART=YES" > /etc/courier/webmaild

You will also need to copy the webmail file from /usr/lib/courier/courier/webmail to the cgi-bin directory of your Apache server.

cp -a /usr/lib/courier/courier/webmail/webmail /srv/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 /srv/www/htdocs/webmail

If you wish to utilze the webadmin utility, 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 /srv/www/cgi-bin

You also need to put the password into the file /etc/courier/webadmin/password:

cat > /etc/courier/webadmin/password << "EOF"
[password]
EOF

If you are not using SSL on your Apache server, you will also need to add /etc/courier/webadmin/unsecureok, so you will be able to use your web based administration tool.

touch /etc/courier/webadmin/unsecureok

If you use Linux-PAM on your system, you will need to create the PAM configuration files:

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

Finally, if you wish to start the Courier server at boot, install the /etc/rc.d/init.d/courier bootscript included in the blfs-bootscripts-6.0 package.

make install-courier

Configuring for virtual users

These instructions will configure Courier to lookup virtual users in a MySQL database. Begin by making the following changes to /etc/courier/authmysqlrc:

MYSQL_SERVER            localhost
MYSQL_USERNAME          courier
MYSQL_PASSWORD          [your choice]
MYSQL_SOCKET            /var/run/mysql/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

Connect to MySQL:

mysql -p

Create the courier_mail database and setup the users table:

CREATE DATABASE courier_mail;
USE courier_mail
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))
);

Grant all priveledges to the courier user created earlier:

GRANT ALL PRIVILEGES ON *.* TO courier@localhost \
    IDENTIFIED BY '[password]' WITH GRANT OPTION;
QUIT

Create a virtual mailman user and group:

groupadd -g 9000 vmailman &&
useradd -c 'Virtual Mailman' -g vmailman -m -k /dev/null -u 9000 vmailman

Create a mail directory for a new virtual user:

cd /home/vmailman &&
mkdir [virtual_user] &&
cd [virtual_user] &&
maildirmake Maildir &&
chown vmailman.vmailman Maildir -R

Now, connect the the MySQL database as the courier user:

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.

Add the first virtual user with the following commands:

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',
''
);

Contents

Installed Programs: addcr, authenumerate, cancelmsg, courier, courier-config, courieresmtpd, courierfilter, courierlogger, couriermlm, couriertcpd, couriertls, deliverquota, dotforward, esmtpd, esmtpd-msa, esmtpd-ssl, filterctl, imapd, imapd-ssl, lockmail, mailbot, maildiracl, maildirkw, maildirmake, maildrop, mailq, 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, webgpg, webmaild
Installed Directories: /etc/courier, /usr/lib/courier, /usr/share/courier, /var/lib/courier, /var/lock/subsys, /var/run/courier and /var/spool/courier

Short Descriptions

cancelmsg

removes a message from the mail queue.

courier

is an administrative command used to control the Courier scheduling engine.

courierfax

sends email messages by fax.

courierfilter

starts and stops all mail filters installed by filterctl.

courierldapaliasd

supports mail address aliasing using an LDAP directory.

courierlogger

captures error messages from other Courier applications and forwards them to the system logger.

couriermlm

sets up, maintains, and manages mailing lists.

courierperlfilter

is a sample filter written in Perl.

courierpop3d

is a Courier POP3 server.

courierpop3login

reads the POP3 userid and password and passes them to the authentication modules.

couriertcpd

accepts incoming network connections, and runs other Courier programs after establishing each network connection.

couriertls

is used by applications to encrypt a network connection using SSL/TLS.

dotforward

is a compatibility module that reads forwarding instructions in $HOME/.forward.

dupfilter

is a threaded filter that tries to block junk E-mail by attempting to detect multiple copies of the same message, which are rejected.

esmtpd

is a control script for courieresmtpd.

esmtpd-msa

is a control script for courieresmtpd, but adds message submission port 587 for the MSA protocol.

filterctl

installs or uninstalls global mail filters.

imapd

is the Courier-IMAP server.

lockmail

is a helper utility for locking mailbox files.

mailbot

is a MIME-aware autoresponder utility.

maildiracl

manages access control lists.

maildirkw

modifies Courier-IMAP compatible maildir message keywords.

maildirmake

creates maildirs, and maildir folders.

maildrop

is a replacement local mail delivery agent that includes a mail filtering language.

mailq

displays a list of all messages that have not been delivered yet.

makeacceptmailfor

builds a list of domains to accept mail for, from the /etc/courier/esmtpacceptmailfor.dir directory.

makealiases

builds an alias database from one or more plain text source files.

makedat

is a utility to create GDBM or DB files from plain text files.

makehosteddomains

rebuilds the contents of the hosteddomains database from the contents of /tools/etc/courier/hosteddomains.

makemime

creates MIME-formatted messages from one or more files.

makepercentrelay

builds a list of %-relayed domains from the percentrelay.dir directory.

makesmtpaccess

builds ESMTP server access files from the /etc/courier/smtpaccess directory.

makesmtpaccess-msa

builds ESMTP server access files from the /etc/courier/smtpaccess directory. This esmtp list is for the MSA protocol.

makeuserdb

builds a user/password db from the contents of /tools/etc/courier/userdb.

mimegpg

signs, encrypts, or decrypts MIME-formatted email messages using GnuPG.

mkesmtpdcert

creates a secure SMTP test certificate.

mkimapdcert

creates a secure IMAP test certificate.

mkpop3dcert

creates a secure POP3 test certificate.

pop3d

is a wrapper script for couriertcpd to start and stop the POP3 service.

pop3d-ssl

is a wrapper script for couriertcpd to start and stop the POP3 over SSL service.

preline

prepends legacy mbox headers to mail messages.

reformail

reads a message on standard input, reformats it in some way, and writes the message to standard output.

reformime

is a utility for reformatting MIME messages.

sendmail

reads an email message and delivers the message to its recipients.

submit

submits messages to Courier for processing.

testmxlookup

lists the names and IP addresses of mail relays that receive mail for the domain.

userdb

is a script to individually manipulate entries in /tools/etc/courier/userdb.

userdbpw

reads a single line of text on standard input, encrypts it, and prints the encrypted result to standard output.

Last updated on 2005-03-14 04:10:36 -0700