Sendmail
Introduction
Sendmail
implements a general purpose internetwork mail routing facility. This document
explain how to install sendmail and run an email server which will send and
receive mail using the SMTP protocol.
An IMAP
or POP3 server is required to retrieve mail using Eudora or MS Outlook.
Sendmail does not offer POP3 or IMAP services.
Installation
Prerequisites
You
should have a basic knowledge of UNIX and DNS.
The
server should allow incoming connections to the SMTP service which will be
listening on TCP port 25.
The
server should have a fully qualified hostname (FQDN) such as mail.example.net.
The
hostname should resolve to an A record. It should not be a CNAME.
The MX
record for the domain for which you wish to receive mail should point to the
hostname of your server.
There
should a PTR record for the IP address of your server. Mail from your server
may be rejected if there is no reverse DNS.
Installing sendmail
- Extract the files from the downloaded file.
- Change the current directory to where the sendmail source code was extracted.
- Enter the following command:
sh Build
- If there are no errors, you may continue with the installation.
- If you are installing sendmail 8.12.x, 8.13.x, or 8.14.x
- Verify whether you have a user smmsp. Create the user if it does not exist. The user should not be assigned a login shell.
- Verify whether you have a group called smmsp.
- Enter the following command:
sh Build install
The
sendmail binary is now installed. The next step is to configure sendmail.
Configuring sendmail
The
main configuration file for sendmail is the /etc/mail/sendmail.cf file.
Starting with version 8.12, sendmail uses the /etc/mail/submit.cf configuration
file for mail submission. The .cf files are complex to understand. It is
recommended that you create a .mc configuration file and use the M4
(macro processor) to generate the .cf file.
There
are some sample .mc configuration files in the cf/cf/ directory
of the sendmail source code. Alternatively, you can use one of the sample
configuration files available from this website. You should edit the .mc file with a UNIX text editor such as
vi.
- Change the current directory to cf/cf directory.
- Copy your .mc configuration file to the current directory as sendmail.mc.
- To generate the sendmail.cf, enter the following command:
sh Build sendmail.cf
- To install the sendmail.cf as /etc/mail/sendmail.cf and submit.cf as /etc/mail/submit.cf, enter the following command:
sh Build install-cf
The
following sample configuration files are available for download. If you are
using a smarthost, you will find a sample configuration here.
If you
already have sendmail installed and configured, you can generate a new
sendmail.cf file by using the following command:
m4 directory/m4/cf.m4 config.mc > sendmail.cf
The
directory for the sendmail m4/cf.m4 file depends on the operating system
you are using:
- Debian /usr/share/sendmail.cf
- FreeBSD /usr/share/sendmail/cf
- MacOS X /usr/share/sendmail/conf
- OpenBSD /usr/share/sendmail
- NetBSD /usr/share/sendmail/cf
- RedHat /usr/share/sendmail-cf or /usr/lib/sendmail-cf
- Slackware 8.0 /usr/src/sendmail/
- Slackware 8.1 /usr/share/sendmail/cf
- Solaris /usr/lib/mail
On
Solaris, for example, type:
m4 /usr/lib/mail/m4/cf.m4 config.mc > sendmail.cf
Verify
whether you have the following files in /etc/mail
- local-host-names
- relay-domains
- aliases
- access
The local-host-names
file should contain the domain name for which your mail server should accept
mail. It is recommended that you also add localhost to this file. Each
entry should be on a new line.
If there
is no relay-domains file, create one with the following command:
touch /etc/mail/relay-domains
The aliases
file should contain the following entries at least:
postmaster: root
abuse: root
security: root
abuse: root
security: root
In the
above example, postmaster is an alias for the root mailbox. The following
command will generate the aliases table:
newaliases
You can
create a new access file by typing
touch /etc/mail/access
The
default database map type for Linux, FreeBSD, NetBSD or OpenBSD is hash.
Type the following to generate the data bases:
makemap hash /etc/mail/access < /etc/mail/access
If you
are using the smarthost.mc or smarthost-dialup.mc, create a genericstable
file and type:
makemap hash
/etc/mail/genericstable < /etc/mail/genericstable
You can
now start sendmail.
Sendmail administration
Starting sendmail
The
sendmail MTA can be started with the following command:
/usr/sbin/sendmail -L sm-mta -bd -q30m
or
/usr/sbin/sendmail -bd -q30m (versions 8.9.x, 8.10.x, 8.11.x)
or
/usr/sbin/sendmail -bd -q30m (versions 8.9.x, 8.10.x, 8.11.x)
The
Mail Submission Agent listens for incoming connections on TCP port 587.
If you
are using sendmail 8.12, 8.13 or 8.14, enter the following command to start the
Mail Submission Program:
/usr/sbin/sendmail -L sm-msp-queue -Ac -q30m
Shutting down sendmail
You can
shutdown sendmail by entering the following command:
kill `head -1 /var/run/sendmail.pid`
Viewing the mail queue
You can
display the contents of the mail queue with the following command:
/usr/bin/mailq
Process messages saved in the mail
queue
You can
process messages saved in the mail queue with the following command:
/usr/sbin/sendmail -q
Troubleshooting
Verifying whether sendmail is running
You can
verify whether sendmail is running by running the following command:
telnet localhost 25
You
will see the sendmail banner which shows the version of sendmail you are using.
Type quit and press Enter to exit to the shell.
Testing SMTP
A SMTP
test can be done to verify email delivery. Type:
telnet mail.example.net 25
Type
the text in bold when you see the following and press Enter
SERVER:220
local ESMTP Sendmail 8.13.5/8.13.5; Wed, 15 Mar 2006 01:51:21 -0800 (PST)
USER:HELO host.example.com
SERVER:250 mail.example.net Hello host.example.com [192.0.2.1], pleased to meet you
USER:MAIL FROM:<user@example.com>
SERVER:250 2.1.0 <user@example.com>... Sender ok
USER:RCPT TO:<postmaster@example.net>
SERVER:250 2.1.5 <postmaster@example.net>... Recipient ok
USER:DATA
SERVER:354 Enter mail, end with "." on a line by itself
USER:This is a test message
USER:.
SERVER:250 2.0.0 k2FApLlB020139 Message accepted for delivery
USER:QUIT
SERVER:221 2.0.0 mail.example.net closing connection
USER:HELO host.example.com
SERVER:250 mail.example.net Hello host.example.com [192.0.2.1], pleased to meet you
USER:MAIL FROM:<user@example.com>
SERVER:250 2.1.0 <user@example.com>... Sender ok
USER:RCPT TO:<postmaster@example.net>
SERVER:250 2.1.5 <postmaster@example.net>... Recipient ok
USER:DATA
SERVER:354 Enter mail, end with "." on a line by itself
USER:This is a test message
USER:.
SERVER:250 2.0.0 k2FApLlB020139 Message accepted for delivery
USER:QUIT
SERVER:221 2.0.0 mail.example.net closing connection
Mail log
The
mail log is usually written to /var/log/maillog
Sendmail configuration files
- /etc/mail/local-host-names
Add the
domains (one per line) for which you want mail to be delivered locally to this
file.
- /etc/mail/relay-domains
If the
system is acting as a secondary MX server, add the domains (one per line) to
this file.
- /etc/mail/aliases
Add
your aliases to this file, then run newaliases to update the data base.
- /etc/mail/access
This
file is used to allow or disallow relaying. The configuration section explains
howto run makemap to update the data base.
File and directory permissions
The
following permissions are generally required for sendmail related files and
directories:
-r-xr-sr-x
root smmsp /usr/sbin/sendmail
drwxrwx--- smmsp smmsp /var/spool/clientmqueue
drwx------ root wheel /var/spool/mqueue
-r--r--r-- root wheel /etc/mail/sendmail.cf
-r--r--r-- root wheel /etc/mail/submit.cf
drwxrwx--- smmsp smmsp /var/spool/clientmqueue
drwx------ root wheel /var/spool/mqueue
-r--r--r-- root wheel /etc/mail/sendmail.cf
-r--r--r-- root wheel /etc/mail/submit.cf
Mail relaying
Mail
relaying occurs when mail is forwarded from someone else through your mail
server. Forwarding mail through a mail server is perfectly natural as long as
either the originator of the message or the receiver is a authorized user. If
neither the sender nor the recipient of the message is a local user, it is
called third-party mail relaying.
Mail
servers should be configured not to accept third-party mail relay. If a mail
server allows third-party mail relaying from everyone, it is known as an open
relay. Such a mail server attracts spammers as it can be used to
send large amounts of junk mail under false identity.
If the
client computer from which you are connecting from has a static IP address, you
can add the following entry, for example, to allowing relaying (send mail):
192.168.0.5
<TAB> RELAY (allows 192.168.0.5 to relay)
192.168.1
<TAB> RELAY (allows 192.168.1/24 to relay)
You
should run the makemap command after modifying the access file.
Mail submission
Sendmail
has been split into two parts, with one part handling mail submission. This
allows sendmail to run without being SUID root.
The
Mail Submission Program (MSP) uses the /var/spool/clientmqueue directory
by default. It will use the /etc/mail/submit.cf configuration file. That
configuration file can be generated from the submit.mc using m4.
The MSP
will send outgoing mail by passing it to localhost on port 25 using the SMTP
protocol. As of sendmail version 8.12.x, you should have sendmail running as a
daemon and listening on localhost at least.
Acronyms
LDA Local
Delivery Agent a program that a mail server uses to deliver mail messages to
the mailboxes of users. This program is also known as local mailer (e.g. mail,
procmail).
MUA
Mail User Agent a program that a user uses to process mail messages (e.g. MS
Outlook, Eudora, Pine, Mutt).
MTA
Mail Transfert Agent a program that a mail server uses to send and receive mail
messages using SMTP (e.g. sendmail).
MSA Mail
Submission Agent.
MSP Mail
Submission Program.
SMTP Simple
Mail Transfer Protocol
2nd Method
Sendmail
Before Installing Sendmail check the
following
- gcc should be installed
- gruff should be installed
First, we want to remove all the RPM
stuff. A general note here. We are removing the RPMs, because we want to write
all of the articles from the perspective of a generic Linux distribution as
much as possible. True, we rely on the default file structure and general
layout of Red Hat; however, by removing the RPMs and compiling/installing from
source, we feel these articles are more useful. OK. On to removing the sendmail
RPMs and related files:
[root@srv-34 /root]# rpm -qa |
grep sendmail
sendmail-8.11.2-14
sendmail-cf-8.11.2-14
[root@srv-34 /root]# rpm -e
sendmail-cf-8.11.2-14
[root@srv-34 /root]# rpm -e
sendmail-8.11.2-14
error: removing these packages would
break dependencies:
smtpdaemon is needed by
fetchmail-5.7.4-4
smtpdaemon is needed by
mutt-1.2.5i-9
[root@srv-34 /root]# rpm -e
fetchmail-5.7.4-4
[root@srv-34 /root]# rpm -e
mutt-1.2.5i-9
[root@srv-34 /root]# rpm -e sendmail-8.11.2-14
[root@srv-34 /root]#
[root@srv-34 /root]# cd
/usr/local/src
[root@srv-34 src]# ls
sendmail.8.11.4.tar.gz
[root@srv-34 src]#
[root@srv-34 src]# tar -xzf *.gz
[root@srv-34 src]# ls
sendmail-8.11.4
sendmail.8.11.4.tar.gz
[root@srv-34 src]# cd send*
[root@srv-34 sendmail-8.11.4]#
Now
let's build sendmail:
[root@srv-34 sendmail-8.11.4]# sh
Build
Making all in:
/usr/local/src/sendmail-8.11.4/libsmutil
.
.
.
cc -O -I. -I../../sendmail
-I../../include -DNEWDB -DNOT_SENDMAIL -c -o vacation.o vacation.c
cc -o vacation vacation.o
../libsmdb/libsmdb.a ../libsmutil/libsmutil.a
-ldb -lresolv -lcrypt -lnsl -ldl
groff -Tascii -man vacation.1 > vacation.0
|| cp vacation.0.dist vacation.0
make[1]: Leaving directory
`/usr/local/src/sendmail-8.11.4/obj.Linux.2.4.2-2.i586/vacation'
[root@srv-34 sendmail-8.11.4]#
All
good. Now what we want to do is build a config.cf file and copy it to
/etc/mail.
[root@srv-34 sendmail-8.11.4]# cd
cf/cf
[root@srv-34 cf]#
[root@srv-34 cf]# ls
Build generic-bsd4.4.mc
generic-solaris2.cf Makefile
chez.cs.mc generic-hpux10.cf
generic-solaris2.mc python.cs.mc
clientproto.mc generic-hpux10.mc
generic-sunos4.1.cf s2k-osf1.mc
cs-hpux10.mc generic-hpux9.cf
generic-sunos4.1.mc s2k-ultrix4.mc
cs-hpux9.mc generic-hpux9.mc
generic-ultrix4.cf tcpproto.mc
cs-osf1.mc generic-linux.cf
generic-ultrix4.mc ucbarpa.mc
cs-solaris2.mc generic-linux.mc
huginn.cs.mc ucbvax.mc
cs-sunos4.1.mc generic-nextstep3.3.cf
knecht.mc uucpproto.mc
cs-ultrix4.mc generic-nextstep3.3.mc
mail.cs.mc vangogh.cs.mc
cyrusproto.mc generic-osf1.cf
mail.eecs.mc
generic-bsd4.4.cf generic-osf1.mc
mailspool.cs.mc
[root@srv-34 cf]#
[root@srv-34 cf]# cat
generic-linux.mc
divert(-1)
#
# Copyright (c) 1998, 1999 Sendmail,
Inc. and its suppliers.
# All rights reserved.
# Copyright (c) 1983 Eric P. Allman.
All rights reserved.
# Copyright (c) 1988, 1993
# The Regents of the University of
California. All rights reserved.
#
# By using this file, you agree to
the terms and conditions set
# forth in the LICENSE file which
can be found at the top level of
# the sendmail distribution.
#
#
#
# This is a generic configuration
file for Linux.
# It has support for local and SMTP
mail only. If you want to
# customize it, copy it to a name
appropriate for your environment
# and do the modifications there.
#
divert(0)dnl
VERSIONID(`$Id: generic-linux.mc,v
8.1 1999/09/24 22:48:05 gshapiro Exp $')
OSTYPE(linux)dnl
DOMAIN(generic)dnl
MAILER(local)dnl
MAILER(smtp)dnl
[root@srv-34 cf]#
[root@srv-34 cf]# mkdir /etc/mail
[root@srv-34 cf]#
[root@srv-34 cf]# mkdir
/var/spool/mqueue
[root@srv-34 cf]#
[root@srv-34 cf]# cp
generic-linux.mc config.mc
[root@srv-34 cf]# sh Build
config.cf
Using M4=/usr/bin/m4
rm -f config.cf
/usr/bin/m4 ../m4/cf.m4 config.mc
> config.cf || ( rm -f config.cf && exit 1 )
chmod 444 config.cf
[root@srv-34 cf]#
[root@srv-34 cf]# cp config.cf
/etc/mail/sendmail.cf
[root@srv-34 cf]#
We need to go back a couple of directories
to the root of the sendmail source tree and install sendmail:
[root@srv-34 cf]# cd ..
[root@srv-34 cf]# cd ..
[root@srv-34 sendmail-8.11.4]# sh
Build install
Making all in:
/usr/local/src/sendmail-8.11.4/libsmutil
.
.
.
install -c -o bin -g bin -m 444
vacation.0 /usr/man/man1/vacation.1
install: cannot create regular file
`/usr/man/man1/vacation.1': No such file or directory
make[1]: *** [install-docs] Error 1
make[1]: Leaving directory
`/usr/local/src/sendmail-8.11.4/obj.Linux.2.4.2-2.i586/vacation'
make: *** [all] Error 2
[root@srv-34 sendmail-8.11.4]#
Hmmmm... Notice how the path for the
man pages is wrong? They should be in /usr/share/man. What we can do to solve
this is to copy /usr/local/src/sendmail-8.11.4/devtools/OS/Linux to /usr/local/src/sendmail-8.11.4/devtools/Site/site.config.m4,
and edit it so that we have:
[root@srv-34 Site]# pwd
/usr/local/src/sendmail-8.11.4/devtools/Site
[root@srv-34 Site]# ls
Linux README site.config.m4
[root@srv-34 Site]# cat
site.config.m4
# $Id: Linux,v 8.18.4.3 2000/12/14
01:04:46 rand Exp $
define(`confDEPEND_TYPE', `CC-M')
define(`confMANROOT',
`/usr/share/man/man')
define(`confLIBS', `-ldl')
define(`confEBINDIR', `/usr/sbin')
APPENDDEF(`confLIBSEARCH', `crypt
nsl')
define(`confLD', `ld')
define(`confMTLDOPTS', `-lpthread')
define(`confLDOPTS_SO', `-shared')
define(`confSONAME',`-soname')
ifelse(confBLDVARIANT, `DEBUG',
dnl Debug build
`
define(`confOPTIMIZE',`-g -Wall')
',
dnl Optimized build
confBLDVARIANT, `OPTIMIZED',
`
define(`confOPTIMIZE',`-O')
',
dnl Purify build
confBLDVARIANT, `PURIFY',
`
define(`confOPTIMIZE',`-g -Wall')
',
dnl default
`
define(`confOPTIMIZE',`-O')
')
[root@srv-34 Site]#
Now, we can try again. We need to
use the -c option because we changed the configuration:
[root@srv-34 sendmail-8.11.4]# sh
Build -c -f /usr/local/src/sendmail-8.11.4/devtools/Site/site.config.m4 install
Making all in:
/usr/local/src/sendmail-8.11.4/libsmutil
Configuration: pfx=, os=Linux,
rel=2.4.2-2, rbase=2, rroot=2.4, arch=i586, sfx=, variant=optimized
.
.
.
-ldb -lresolv -lcrypt -lnsl -lcrypt
-lnsl -ldl
install -c -o bin -g bin -m 555
vacation /usr/bin
groff -Tascii -man vacation.1 >
vacation.0 || cp vacation.0.dist vacation.0
install -c -o bin -g bin -m 444
vacation.0 /usr/share/man/man1/vacation.1
make[1]: Leaving directory
`/usr/local/src/sendmail-8.11.4/obj.Linux.2.4.2-2.i586/vacation'
[root@srv-34 sendmail-8.11.4]#
OK. That worked. We need to create
an empty (for now) local-host-names file:
[root@srv-34 mail]# cat /dev/null
> local-host-names
Let's go over to srv-33 and do the
same thing, but this time we will run a mail daemon. We need to create a
/etc/aliases.db file. For now, we will just create an empty /etc/aliases and
run newaliases:
[root@srv-33 /root]# cat
/dev/null > /etc/aliases
[root@srv-33 /root]# newaliases
/etc/mail/aliases: 0 aliases,
longest 0 bytes, 0 bytes total
[root@srv-33 /root]#
Let's start the daemon manually:
[root@srv-33 sendmail-8.11.4]# sendmail
-bd -q30m
Now, on srv-34... First, let's send
mail:
[root@srv-34 log]# sendmail
u-1@srv-33
test from srv-34
.
Now, let's check the logs on srv-34:
[root@srv-34 log]#
[root@srv-34 log]# cat
/var/log/maillog
.
.
.
Jun 11 13:49:15 srv-34
sendmail[10794]: f5BKmwd10794: from=root, size=19,
class=0, nrcpts=1,
msgid=<200106112048.f5BKmwd10794@srv-34.signalq.com>,
relay=root@localhost
Jun 11 13:49:15 srv-34
sendmail[10796]: f5BKmwd10794: to=u-1@srv-33,
ctladdr=root (0/0), delay=00:00:17,
xdelay=00:00:00, mailer=esmtp, pri=30019,
relay=srv-33.signalq.com.
[10.50.100.51], dsn=2.0.0, stat=Sent (f5BKlg906302i
Message accepted for delivery)
[root@srv-34 log]#
OK. Let's get our mail via pine on
srv-34, logging on to the u-1 account on srv-33 via IMAP:
[root@srv-34 sendmail-8.11.4]# pine
PINE 4.33 MESSAGE TEXT Folder: INBOX
Message 3 of 3 ALL
Return-Path:
Received: from srv-34.signalq.com
(srv-34.signalq.com [10.50.100.53])
by srv-33.signalq.com
(8.11.4/8.11.4) with ESMTP id f5BKlg906302
for ; Mon, 11 Jun 2001 13:47:42
-0700
Received: (from root@localhost)
by srv-34.signalq.com
(8.11.4/8.11.4) id f5BKmwd10794
for u-1@srv-33; Mon, 11 Jun 2001
13:48:58 -0700
Date: Mon, 11 Jun 2001 13:48:58
-0700
From: root
Message-Id: <200106112048.f5BKmwd10794@srv-34.signalq.com>
test from srv-34
[Already at end of message]
? Help J Jump H HdrMode * Flag
O OTHER CMDS : SelectCur Tab NextNew
B Bounce | Pipe
We can see this stuff on srv-33's
logs:
[root@srv-33 mail]# cat
/var/log/maillog
Jun 11 13:47:42 srv-33
sendmail[6302]: f5BKlg906302: from=, size=302, class=0, nrcpts=1,
msgid=<200106112048.f5BKmwd10794@c
allisto .signalq.com>,
proto=ESMTP, daemon=MTA, relay=srv-34.signalq.com [10.5
0.100.53]
Jun 11 13:47:42 srv-33
sendmail[6303]: f5BKlg906302: to=, delay=00:00:00, xdelay=00:00:00,
mailer=local, pri=30026, dsn=2.0.
0, stat=Sent
Jun 11 13:48:26 srv-33 imapd[6305]:
imap service init from 10.50.100.53
Jun 11 13:48:32 srv-33 imapd[6305]:
Authenticated user=u-1 host=srv-34.s
ignalq.com [10.50.100.53]
Let's start sendmail automatically
by adding: /usr/sbin/sendmail -bd -q30m to the bottom of /etc/rc.d/rc.local.
Do
note that we have configured very little here, and we have not addressed
security issues. We will cover this in other articles.
Configuring
Your POP Mail Server
Each user on your Linux box will get mail sent to their
account's mail folder, but sendmail just handles mail sent to your my-site.com
domain. If you want to retrieve the mail from your Linux box's user account
using a mail client such as Evolution, Microsoft Outlook or Outlook Express,
then you have a few more steps. You'll also have to make your Linux box a POP
mail server.
Fedora Linux comes with the easy to use dovecot IMAP/POP
server RPM package which requires very little configuration after installation.
Most
RedHat and Fedora Linux software products are available in the RPM format. You
will need to make sure that the dovecot software RPM is installed. (Chapter 6,
"Installing RPM Software", will tell
you how.) When searching for the RPMs, remember that the filename usually
starts with the software package name by a version number, as in
dovecot-0.99.11-1.FC3.4.i386.rpm.
You can use the chkconfig command to get dovecot
configured to start at boot:
[root@bigboy
tmp]# chkconfig dovecot on
To start, stop, and restart dovecot after booting, use
[root@bigboy
tmp]# service dovecot start
[root@bigboy
tmp]# service dovecot stop
[root@bigboy
tmp]# service dovecot restart
Remember to restart the dovecot process every time you
make a change to the configuration files for the changes to take effect on the
running process. You can also test whether the dovecot process is running with
the pgrep command:
[root@bigboy
tmp]# pgrep dovecot
You should get a response of plain old process ID
numbers:
You can define most of dovecot's configuration parameters
in the /etc/dovecot.conf file. By default dovecot will act as a server for
IMAP, secure IMAP (IMAPS), POP and secure POP (POPS). You can limit this list
by editing the protocols line in the /etc/dovecot.conf file and then restarting
dovecot for the change to take effect. In the example below dovecot is
configured to serve only POP3.
#
#
File /etc/dovecot.conf sample
#
#
Protocols we want to be serving imap imaps pop3 pop3s
#protocols
= imap imaps pop3 pop3s
protocols
= pop3
You can then use the netstat command to do a simple
preliminary test to make sure dovecot is serving POP3 only.
[root@bigboy
tmp]# netstat -a | egrep -i 'pop|imap'
tcp
0 0 *:pop3 *:* LISTEN
[root@bigboy
tmp]#
In
order to use SquirrelMail, you should take the following steps.
Download
all required software
You
can find SquirrelMail package on SquirrelMail site.
PHP can be found on PHP site.
Install
webserver and PHP (at least 4.1.0).
SquirrelMail
needs a webserver with PHP support. Check PHP
install manual for information about supported web servers
and install procedures.
Some
Linux and Unix distributions provide precompiled web server and php packages.
We
recommend the following PHP settings:
- register_globals off - a dangerous setting, not needed. We do not release security advisories for issues only exploitable with this setting on. Note that you can easily enable it only for some legacy site that may need it and turn it off globally.
- magic_quotes_{runtime,gpc,sybase} off - SquirrelMail may work with any of these on, but if you experience stray backslashes in your mail or other strange behaviour, it may be advisable to turn them off.
- file_uploads on - needed if your users want to attach files to their mails.
- safe_mode on or off - safe_mode on is only a tiny bint more secure, in the SquirrelMail case. There may be some incompatibilities with some functionality (see Safe mode).
Install
IMAP server
It
depends on used email system. Email server needs IMAP service that knows used
email system layout. If you use Unix with standard sendmail server, you might
have to install UW IMAP, Dovecot or other IMAP server, that can use email
stored in /var/spool/mail/ directory. If you use Windows, you might have to
enable IMAP service that is bundled with your email server. If your email
server does not support IMAP, you might have to find some other email server
product.
Unpack
SquirrelMail package
Unpack
the SquirrelMail package in a web-accessible location.
Prepare
data and attachment directories
Select
a data-dir and attachment dir, outside the webtree (e.g. in /var). The data-dir
(for user prefs) should be owned by the user the webserver runs as (e.g.
www-data). The attachment dir (for uploading files as attachments) should be
file mode 0730 and in the same group as the webserver.
If
you use PHP with safe mode enabled, check chapter about safe mode.
Configure
SquirrelMail
Run
config/conf.pl
from the command line. Use the D option to load predefined options for specific
IMAP servers, and edit at least the Server Settings and General Options
(datadir).
Check
your SquirrelMail configuration
Browse
to http://example.com/yourwebmaillocation/src/configtest.php to test your
configuration for common errors.
Log
into SquirrelMail
Browse
to http://example.com/yourwebmaillocation/ to log in.
This
chapter covers installation of SquirrelMail on generic Unix or Linux system. It
does not cover installation of operating system or tools required to install
web server or PHP.
Any
version numbers used in examples are specific to the time when this documentation
is written. If current version numbers differ, make sure that you are not using
old, obsolete or vulnerable software.
Guide
uses UW IMAP server as example. This IMAP server can be used in generic email
setup when incoming mail is stored in /var/spool/mail directory. If you are planning to use webmail with big
number of users or with bigger mailboxes, consider using different IMAP server
and redesign entire email system.
Download
required software
You
will need:
- Apache - http://httpd.apache.org/download.cgi
- PHP - http://php.net/downloads.php
- UW IMAP - http://www.washington.edu/imap/
- SquirrelMail - http://squirrelmail.org/download.php
# install -d
/usr/local/src/downloads
# cd /usr/local/src/downloads
# wget
http://some-apache-mirror-server/apache/httpd/httpd-2.0.54.tar.gz
# wget http://some-php-mirror-server/get/php-4.3.11.tar.bz2/from/this/mirror
# wget
ftp://ftp.cac.washington.edu/mail/imap.tar.Z
# wget
http://some-sourceforge-mirror/some-path/squirrelmail-1.4.5.tar.bz2
Unpack
and install apache
# cd /usr/local/src
# tar -xzvf
/usr/local/src/downloads/httpd-2.0.54.tar.gz
# cd httpd-2.0.54
# ./configure
--prefix=/usr/local/apache --enable-module=so
# make
# make install
Unpack
and install php
# cd /usr/local/src
# tar --bzip2 -xvf
/usr/local/src/downloads/php-4.3.11.tar.bz2
# cd php-4.3.11
# ./configure
--prefix=/usr/local/php \
>
--with-apxs2=/usr/local/apache/bin/apxs
# make
# make install
If
you configure PHP compilation with --disable-all option, you must add --enable-session and --with-pcre-regex options.
Add
PHP support to apache
<IfModule mod_php4.c>
AddType application/x-httpd-php .php
</IfModule>
Restart
apache and check if php is working
/usr/local/apache/bin/apachectl
graceful
<?php phpinfo(); ?>
Unpack
and install imap server
Unpack
UW IMAP archive.
# cd /usr/local/src
# tar -xzvf
/usr/local/src/downloads/imap.tar.Z
Compile
UW IMAP
cd
/usr/local/src/imap-<someversion>
make port-name EXTRADRIVERS=''
SSLTYPE=unix
Replace
port-name with name that
matches your system. Check Makefile for possible values. If you haven't
installed OpenSSL libraries and headers, use SSLTYPE=none instead of SSLTYPE=unix.
Install
IMAP server binary
strip imapd/imapd
install -d /usr/local/libexec/
cp imapd/imapd /usr/local/libexec/
Enable
IMAP server in inetd.conf
imap2 stream tcp nowait root
/usr/sbin/tcpd /usr/local/libexec/imapd
Restart
inetd
Prepare
SquirrelMail directories
# mkdir /usr/local/squirrelmail
# cd /usr/local/squirrelmail
# mkdir data temp
# chgrp nogroup data temp
# chmod 0730 data temp
Unpack
SquirrelMail
# cd /usr/local/squirrelmail
# tar --bzip2 -xvf
/usr/local/src/downloads/squirrelmail-1.4.5.tar.bz2
# mv squirrelmail-1.4.5 www
Configure
SquirrelMail
Start
SquirrelMail configuration utility. Configure SquirrelMail with UW preset. Set
data and attachment directories.
Configure
access to SquirrelMail in Apache
Modify
httpd.conf
Alias /squirrelmail
/usr/local/squirrelmail/www
<Directory /usr/local/squirrelmail/www>
Options Indexes
AllowOverride none
DirectoryIndex index.php
Order allow,deny
allow from all
</Directory>
Log
into SquirrelMail
After
you add alias to SquirrelMail in apache configuration and restart apache, you
should be able to access SquirrelMail by going to http://your-server/squirrelmail.
Comments
Post a Comment