Typo
[linux_from_scratch_hints.git] / OLD / courier.txt
blobda17c2e29fb767d2bcb5ec3b5415beb69de5ce02
1 AUTHOR:         Jim Gifford <lfs-hints@jg555.com>
3 DATE:           2003-09-09
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
13                 mysql aspell-0.50.3
15 HINT:
16         
17 courier-0.43.2
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
23 Version used:                   0.43.2
24 Package size:                   3.1 MB
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.
35 courier depends on:
36         gdbm-1.8.3
37         expect-5.39(see below for installation information) 
38         Linux_PAM-0.77 apache openssl-0.97
39         
40         Notes - db-4.0.14 will also work
41                 db-4.1.25 does not work, causes problems with makealiases
43 courier can utilize:
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" \
53         >> /etc/passwd  
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
68         make &&
69         make install &&
70         make install-configure
71         
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
79         
80         You will need edit the following entries
81         
82         MYSQL_SERVER            mysql.example.com
83         MYSQL_SERVER            localhost
84         
85         MYSQL_USERNAME          admin
86         MYSQL_USERNAME          courier
87         
88         MYSQL_PASSWORD          admin
89         MYSQL_PASSWORD          (your choice) (This is the db password)
91         # MYSQL_SOCKET          /var/mysql/mysql.sock
92         MYSQL_SOCKET            /tmp/mysql.sock
94         MYSQL_PORT              0
95         MYSQL_PORT              3306
97         MYSQL_DATABASE          mysql
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
112         PAM Configuration
114         /etc/courier/esmtp
115         
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
124         /etc/courier/pop3
125         
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
134         /etc/courier/imap
135         
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
144         /etc/courier/webmail
145         
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
154 MySQL Configuration
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
164         CREATE TABLE users (
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,
173         KEY id (id(128))
174         );
176         This will add the courier user that we specified earlier in 
177         the authmysql file.
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
187         specified.
189         /etc/courier/defaultdomain
191         cat > /etc/courier/defaultdomain << "EOF"
192         {yourdomain}
193         EOF
195         /etc/courier/locals
197         cat > /etc/courier/locals << "EOF"
198         localhost
199         {yourdomain}
200         EOF
202         /etc/courier/esmtpacceptmailfor
204         cat > /etc/courier/esmtpacceptmailfor << "EOF"
205         localhost
206         {yourdomain}
207         EOF
209         /etc/courier/hosteddomains
210         
211         cat > /etc/courier/hosteddomains << "EOF"
212         {yourdomain}
213         EOF
215         /etc/courier/me
216         
217         cat > /etc/courier/me << "EOF"
218         {yourdomain}
219         EOF
221         You will also need to edit the aliases file and change the 
222         following entry.
224         /etc/courier/aliases/system
226         postmaster:
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 
233         following commands
235         makesmtpaccess
236         makehosteddomains
237         makealiases
238         
239 SMTP/SMTMP-SSL Configuration
241         This section will enable the SMTP Server from Courier
243         /etc/courier/esmtpd
245         You will need edit the follow entries
247         ESMTPDSTART=NO
248         ESMTPDSTART=YES
250         /etc/courier/esmtpd-ssl
252         ESMTPDSSLSTART=NO
253         ESMTPDSSLSTART=YES
255 POP3/POP3-SSL Configuration
257         This section will enable the POP3 Server from Courier
259         /etc/courier/pop3d
261         You will need edit the follow entries
263         POP3DSTART=NO
264         POP3DSTART=YES
266         /etc/courier/pop3d-ssl
268         POP3DSSLSTART=NO
269         POP3DSLLSTART=YES
271 IMAP/IMAP-SSL Configruation
273         This seciton will enable the IMAP Server from Courierd
275         /etc/courier/imapd
277         You will need to edit the following entries
279         IMAPDSTART=NO
280         IMAPDSTART=YES
282         /etc/courierd/imapd-ssl
284         IMAPDSSLSTART=NO
285         IMAPDSSLSTART=YES
287 Creating Maildirectories for System Users
289         This section will explain on how to create MailDirs for your 
290         system users.
292         cd /home/{username}
293         maildirmake Maildir
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" \
301         >> /etc/passwd
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.
308         cd /home/vmailman
309         mkdir {virtual_user}
310         cd {virtual_user}
311         maildirmake Maildir
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'});
325         example
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".
338         
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
345         maildirmake .ISP1
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
355         # Global Variables
356         #
357         DEFAULT="$HOME/Maildir"
358         LOGDIR="$HOME/log"
360         # Log File
361         #
362         logfile "$LOGDIR/maildroprc.log"
364         # Drop anything listed as a Virus into .Virus
365         #
366         if (/^Subject:.*VIRUS FROM*/)
367                 to "$DEFAULT/.Virus/"
369         # Drop anything listed as Spam into .Spam
370         #
371         if (/^X-Spam-Flag: *YES/)
372           to "$DEFAULT/.Spam/"
375         For Individual Maildrop procedures, you will need to create the 
376         file ~/.mailfilter. You can use Global and Individual Maildrop 
377         procedures. 
379         Here is an example of a .mailfilter file. These rules will work on
380         a individual basis.
382         # Begin /~/.mailfilter
384         # Local maildrop filter
386         # Global Variables
387         #
388         DEFAULT="$HOME/Maildir"
389         LOGDIR="$HOME/log"
391         # Log File
392         #
393         logfile "$LOGDIR/maildroprc.log"
395         # ISP1 Email into File ISP1
396         #
397         if (/^(To|[Cc][Cc][Mail-Followup-to]):.*userfrom@isp1.com*/)
398           to "$DEFAULT/.ISP1/"
400         # Courier Maillist into Folder Courier
401         #
402         if (/^List-Post:.*courier-users@lists.sourceforge.net*/)
403           to "$DEFAULT/.Courier/"
407 # End /~/.mailfilter
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
440 Version used:                   5.39
441 Package size:                   505 KB
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
455         make &&
456         make install &&
457         
458         # Note - If you also have tk installed, you can add 
459                    --with-tk=/usr/lib \
460                    --with-tkinclude=/usr/include/tk
462 ----Amavis 0.312----
464         To use amavis with Courier you will need to download the patch at
465         http://www.jg555.com/projects/patches/amavis.php        
468 VERSION:        1.7
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
475                 1.2 Fixed Typos
476                 1.1 Added Information about Amavis Patch
477                 1.0 Initial Version
479  New Version of this document can be viewed from http://www.jg555.com/cvs