Courier-0.43.2

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. The configuration listed below will allow users with PAM and virtual-users in a MySQL Database access to email.

Package information

Installation of Courier

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

Install courier by running the following commands:

./configure --prefix=/usr --sysconfdir=/etc/courier --with-piddir=/var/run \
--libexecdir=/usr/sbin --datadir=/usr/share/courier \
--localstatedir=/var/spool/courier --disable-root-check --with-db=gdbm \
--with-mailuser=courier --with-mailgroup=courier \
--enable-workarounds-for-imap-client-bugs \
--with-ispell=/usr/bin/aspell &&
make &&
make install &&
make install-configure

Command explanations

--sysconfdir=/etc/courier: Specifies the directory where Courier's configuration files are installed.

--with-piddir=/var/run: Specifies the directory where Courier's PID files are stored when Courier is active.

--libexecdir=/usr/sbin: libexecdir 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. This option defaults to the subdirectory var in the directory specified by the --prefix option.

--disable-root-check: Allows Courier to be built as the root user.

--with-db=gbbm: Courier requires either the GDBM or the DB database library. GDBM is used if both are present. This option forces the selection of the database library.

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

--withmailgroup=courier: like --with-mailuser, but specifies the group ID.

--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-ispell=/usr/bin/aspell: Courier's webmail server can use spell checking, if the aspell program is available. If configure finds ispell, spell checking is enabled. If aspell is not in the current search path, use --with-ispell=program to explicitly set the location of aspell.

Configuring Courier

Config files

/etc/courier/authmysqlrc

Configuration Information

Make the following changes in this 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

This command will create the mysql database for authentication:

mysqladmin -uroot -p[password] create courier-mail

This command will setup the table users for the courier-mail database:

mysql -uroot -p[password] 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))
        );

This will add the courier user that we specified earlier in the authmysql file:

mysql -uroot -p[password] mysql

grant all privileges on *.* to courier@localhost identified by '[password]' with grant option;

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.

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

echo "vmailman:x:9000:9000:Virtual Mailman:/home/vmailman:/bin/bash" >> /etc/passwd
echo "vmailman:x:9000:" >> /etc/group

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

Add the virtual user to the MySQL database. You need to enter at least on version of the password either clear text or encrypted.

mysql -ucourier -p[password] 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']);

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 file webmail from /usr/sbin/courier/webmail/webmail to your cgi-bin directory of your Apache server.

cp -a /usr/sbin/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 file webadmin from /usr/sbin/courier/webmail/webmin to your cgi-bin directory of your Apache server.

cp -a /usr/sbin/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 follow commands:

cp /usr/src/courier-0.43.2/courier.sysvinit /etc/rc.d/init.d/courier &&
chmod 755 /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

Contents

The Courier package contains cancelmsg, courier-config, couriermlm, couriertls, deliverquota, dotforward, imapd, lockmail, mailbot, maildirkw, maildrop, mailq, makedat, makemime, mimegpg, preline, reformail, reformime, rmail, sendmail, testmxlookup, courier, courierfilter, courierlogger, couriertcpd, esmtpd, esmtpd-msa, esmtp-ssl, filterctl, imapd, imapd-ssl, makeacceptmailfor, makealiases, makehosteddomains, makepercentrelay, makesmtpacces, makesmtpaccess-msa, makeuserdb, makeuucpneighbors, mksmtpcert, mkimapdcert, mkpop3cert, pop3d, pop3d-ssl, pw2userdb, showconfig, showmodules, userdb, userdbpw, webgpg, authdaemon, authdaemon.mysql, authdaemon.plain, aliascombine, aliascreate, aliasexp, courierd, courierpop3d, courierpop3login, imaplogin, makedatprog, pcpd, submit, submitmkdir, webadmin, webmail, courierdsn, addcr, authend, authstate, courieresmtp, courieresmtpd, courierfax, courierdeliver, courierlocal, courieruucp, perlfilter, dupfilter.

Description

cancelmsg

cancelmsg removes a message from the mail queue.

couriermlm

couriermlm is the Courier mailing list manager.

lockmail

lockmail is a helper utility for working with mailbox files..

mailbot

mailbot reads an E-mail message on standard input and creates an E-mail message replying to the original message's sender..

maildirkw

maildirkw modifies Courier-IMAP compatible maildir message keywords.

maildrop

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

mailq

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

reformail

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

reformime

reformime is a utility for reformatting MIME messages.

sendmail

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.

testmxlookup

testmxlookup lists the names and IP addresses of mail relays that receive mail for the domain. This is useful in diagnosing mail delivery problems..

courier

courier 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

courierfilter commands install or uninstall global mail filters. Global mail filters are used to selectively block unwanted mail.

filterctl

filterctl commands install or uninstall global mail filters. Global mail filters are used to selectively block unwanted mail.

makeacceptmailfor

makeacceptmailfor Build a list of domains to accept mail for from the /etc/courier/esmtpacceptmailfor.dirdirectory.

makealiases

makealiases Build a list of aliases from /etc/courier/aliases or /etc/courier/aliasdir directories.

makehosteddomains

makehostedomains Build a database of hosted domains from hosteddomains .

makepercentrelay

makepercentrelay Build a list of %-relayed domains from percentrelay.dir directory.

makesmtpaccess

makesmtpacces Build ESMTP server access file from /etc/courier/smtpaccess directory.

makesmtpaccess-msa

makesmtpaccess-msa Build ESMTP server access file from /etc/courier/smtpaccess directory. This esmtp list is for the MSA protocol.

makeuucpneighbors

makeuucpneighbors Builds a list of UUCP recipient's using /etc/courier/uucpneighbors .

showconfig

showconfig Shows the current Courier configuration.

showmodules

showmodules Shows the current Courier modules.

authdaemon

authdaemon Courier Authentication Library.

.