1 AUTHOR: Jim Gifford <lfs-hints@jg555.com>
5 LICENSE: GNU Free Documentation License Version 1.2
7 SYNOPSIS: Courier Mail Server for setup
9 DESCRIPTION: This hint will show you how to install the Courier Mail
10 Server with virutial users using mysql.
12 PREREQUISITES: gdbm-1.8.3 expect-5.39 Linux_PAM-0.77 apache openssl-0.97
18 Introduction to courier
19 Download location (HTTP):
20 http://osdn.dl.sourceforge.net/sourceforge/courier/courier-0.43.2.tar.bz2
21 Download location (FTP):
22 ftp://courier.sourceforge.net/courier/courier-0.43.2.tar.bz2
25 Estimated Disk space required: 55 MB
28 The courier package contains a Mail Transport Agent (MTA). This is useful
29 for sending email to other users of your host machine. It can also be
30 configured to be a central mail server for your domain or a mail relay agent.
31 The courier packages also includes a web-based email interface, IMAP, IMAP-SSL,
32 POP3, and POP3-SSL. The configuration listed below will allow users with PAM
33 and virtual-users in a Mysql Database access to email.
37 expect-5.39(see below for installation information)
38 Linux_PAM-0.77 apache openssl-0.97
40 Notes - db-4.0.14 will also work
41 db-4.1.25 does not work, causes problems with makealiases
44 mysql-3.23.55 mysql-4.0.15 aspell-0.50.3
46 Installation of courier
48 Before you compile the program, you need to create users and groups that
49 will be expected to be in place when the install script executes. Add
50 the users and groups with the following commands:
52 echo "courier:x:103:103:Courier Mail Server:/dev/null:/bin/false" \
54 echo "courier:x:103:" >> /etc/group
56 You may change the 103 to your particular needs.
58 Install courier by running the following commands:
60 ./configure --prefix=/usr --sysconfdir=/etc/courier \
61 --with-piddir=/var/run \
62 --libexecdir=/usr/libexec --datadir=/usr/share/courier \
63 --localstatedir=/var/lib/courier --disable-root-check \
64 --with-db=gdbm --with-mailuser=courier \
65 --withmailgroup=courier \
66 --enable-workarounds-for-imap-client-bugs \
67 --with-ispell=/usr/bin/aspell
70 make install-configure
72 # Note - You may receive an error saying that the mime.types file could
73 not be found. This can easily be corrected by adding
74 --enable-mimetypes=(location of mime.types file)
76 Configure authentication
78 /etc/courier/authmysqlrc
80 You will need edit the following entries
82 MYSQL_SERVER mysql.example.com
83 MYSQL_SERVER localhost
86 MYSQL_USERNAME courier
89 MYSQL_PASSWORD (your choice) (This is the db password)
91 # MYSQL_SOCKET /var/mysql/mysql.sock
92 MYSQL_SOCKET /tmp/mysql.sock
98 MYSQL_DATABASE courier-mail
100 MYSQL_USER_TABLE passwd
101 MYSQL_USER_TABLE users
103 #MYSQL_CLEAR_PWFIELD clear
104 MYSQL_CLEAR_PWFIELD clear
106 #DEFAULT DOMAIN example.com
107 DEFAULT DOMAIN (your domain)
109 #MYSQL_QUOTA_FIELD quota
110 MYSQL_QUOTA_FIELD quota
116 # Begin /etc/pam.d/esmtp
118 auth required pam_unix.so try_first_pass
119 account required pam_unix.so
120 session required pam_unix.so
122 # End /etc/pam.d/esmtp
126 # Begin /etc/pam.d/pop3
128 auth required pam_unix.so try_first_pass
129 account required pam_unix.so
130 session required pam_unix.so
132 # End /etc/pam.d/pop3
136 # Begin /etc/pam.d/imap
138 auth required pam_unix.so try_first_pass
139 account required pam_unix.so
140 session required pam_unix.so
142 # End /etc/pam.d/imap
146 # Begin /etc/pam.d/webmail
148 auth required pam_unix.so try_first_pass
149 account required pam_unix.so
150 session required pam_unix.so
152 # End /etc/pam.d/webmail
156 This section will create the mysql database for authentication.
158 mysqladmin -uroot -p{password} create courier-mail
160 This section will setup the table users for the courier-mail database.
162 mysql -uroot -p{password} courier-mail
165 id char(128) DEFAULT '' NOT NULL,
166 crypt char(128) DEFAULT '' NOT NULL,
167 clear char(128) DEFAULT '' NOT NULL,
168 name char(128) DEFAULT '' NOT NULL,
169 uid int(10) unsigned DEFAULT '65534' NOT NULL,
170 gid int(10) unsigned DEFAULT '65534' NOT NULL,
171 home char(255) DEFAULT '' NOT NULL,
172 quota char(255) DEFAULT '' NOT NULL,
176 This will add the courier user that we specified earlier in
179 mysql -uroot -p{password} mysql
181 grant all privileges on *.* to courier@localhost
182 identified by '{password}' with grant option;
184 General Settings for Mail
186 You will need to create the following files with the contents
189 /etc/courier/defaultdomain
191 cat > /etc/courier/defaultdomain << "EOF"
197 cat > /etc/courier/locals << "EOF"
202 /etc/courier/esmtpacceptmailfor
204 cat > /etc/courier/esmtpacceptmailfor << "EOF"
209 /etc/courier/hosteddomains
211 cat > /etc/courier/hosteddomains << "EOF"
217 cat > /etc/courier/me << "EOF"
221 You will also need to edit the aliases file and change the
224 /etc/courier/aliases/system
227 postmaster: {your adminstrator email}
229 If you want to deny access from some hosts from sending mail you
230 will need to edit the /etc/courier/smtpaccess/default.
232 After the above steps are completed you will need to run the
239 SMTP/SMTMP-SSL Configuration
241 This section will enable the SMTP Server from Courier
245 You will need edit the follow entries
250 /etc/courier/esmtpd-ssl
255 POP3/POP3-SSL Configuration
257 This section will enable the POP3 Server from Courier
261 You will need edit the follow entries
266 /etc/courier/pop3d-ssl
271 IMAP/IMAP-SSL Configruation
273 This seciton will enable the IMAP Server from Courierd
277 You will need to edit the following entries
282 /etc/courierd/imapd-ssl
287 Creating Maildirectories for System Users
289 This section will explain on how to create MailDirs for your
294 chown {username}.{username} Maildir -R
296 Setup for Virtual users
298 This section will explain how to setup Maildir for your virtual users.
300 echo "vmailman:x:9000:9000:Virtual Mailman:/home/vmailman:/bin/bash" \
302 echo "vmailman:x:9000:" >> /etc/group
304 You may change the 9000 to your particular needs.
306 Now to setup the maildir for these virutal users.
312 chown vmailman.vmailman Maildir -R
314 Add the virtual user to the MySQL database. You need to enter at least on
315 version of the password either clear text or encrypted.
317 mysql -ucourier -p{password} courier-mail
319 insert into users values('{virtual_users}@{domain.com},
320 '{encrypted password or blank}',
321 '{clear text password or blank}',
322 '{User's Name}',9000,9000,
323 '{location of Maildir}','{Quota in Bytes'});
327 insert into users values ('blfsuser@linuxfromscratch.org','','password',
328 'BLFS User',9000 ,9000,
329 '/home/vmailman/blfsuser','');
331 Setup for Mail Drop Procedures
333 This section will give examples on how to setup Maildrop with Courier.
335 If you use this feature, you will need to edit your
336 /etc/courier/courierd file and change the line DEFAULTDELIVERY=./Maildir
337 to DEFAULTDELIVERY="| /usr/bin/maildrop".
339 Remember if you are using folders, you will need to create them using
340 the command maildirmake .(Foldername) the . is required. For example if
341 you need to create a folder named ISP1 for the user jeff, you would
342 follow this procedure.
344 cd /home/jeff/Maildir
346 chown jeff.jeff .ISP1 -R
348 For Global MailDrop procedures, you will need to create the file
349 /etc/courier/maildroprc.
351 Here is an example of a maildroprc file. These rules will work globally.
353 # Global maildrop filter
357 DEFAULT="$HOME/Maildir"
362 logfile "$LOGDIR/maildroprc.log"
364 # Drop anything listed as a Virus into .Virus
366 if (/^Subject:.*VIRUS FROM*/)
367 to "$DEFAULT/.Virus/"
369 # Drop anything listed as Spam into .Spam
371 if (/^X-Spam-Flag: *YES/)
375 For Individual Maildrop procedures, you will need to create the
376 file ~/.mailfilter. You can use Global and Individual Maildrop
379 Here is an example of a .mailfilter file. These rules will work on
382 # Begin /~/.mailfilter
384 # Local maildrop filter
388 DEFAULT="$HOME/Maildir"
393 logfile "$LOGDIR/maildroprc.log"
395 # ISP1 Email into File ISP1
397 if (/^(To|[Cc][Cc][Mail-Followup-to]):.*userfrom@isp1.com*/)
400 # Courier Maillist into Folder Courier
402 if (/^List-Post:.*courier-users@lists.sourceforge.net*/)
403 to "$DEFAULT/.Courier/"
410 Setup for Web-based Email
412 This section will explain how to setup Courier Web-based email system.
414 You will need to copy the file webmail from /usr/libexec/courier/webmail
415 to your cgi-bin directory of you Apache server.
417 cp -a /usr/libexec/courier/webmail/webmail /var/www/cgi-bin
419 You will then need to copy the images to a folder under your htdocs
420 directory of your Apache server. The directory needs to be named webmail
421 or you need to specify it during the configure phase with
422 --enable-imageurl=/url.
424 cp -a /usr/share/courier/sqwebmail/images /var/www/htdocs/webmail
426 Setup for Web-based Administration
428 This section will explain how to setup Courier Web-based admin system.
430 You will need to copy the file webadmin from /usr/libexec/courier/webmail
431 to your cgi-bin directory of you Apache server.
433 cp -a /usr/libexec/courier/webmail/webadmin /var/www/cgi-bin
435 -----Expect 5.39-----
437 This section will explain how to setup expect for Webadmin and Webmail.
439 Download location (FTP): ftp://expect.nist.gov/expect.tar.gz
442 Estimated Disk space required: 5 MB
444 Introduction to expect
446 Expect is a tool for automating interactive applications such as telnet, ftp,
447 passwd, fsck, rlogin, tip, etc. Expect really makes this stuff trivial. Expect
448 is also useful for testing these same applications. And by adding Tk, you can
449 also wrap interactive applications in X11 GUIs.
451 Install expect by running the following commands:
453 ./configure --prefix=/usr --with-tcl=/usr/lib \
454 --with-tclinclude=/usr/include/tcl
458 # Note - If you also have tk installed, you can add
460 --with-tkinclude=/usr/include/tk
464 To use amavis with Courier you will need to download the patch at
465 http://www.jg555.com/projects/patches/amavis.php
470 CHANGELOG: 1.7 Updated Package, fixed for new db issue
471 1.6 Updated to New Hint Format Completed
472 1.5 Updated Email Address
473 1.4 Updated to New Hint Format
474 1.3 Updated to Version 0.43.1 and added me file
476 1.1 Added Information about Amavis Patch
479 New Version of this document can be viewed from http://www.jg555.com/cvs