This chapter gives you a quick introduction to setting up Exim and an overview of its functionality. Although Exim is largely compatible with sendmail in its behavior, its configuration files are completely different.
The main configuration file is usually called
/etc/exim.conf
or /etc/exim/config
in most Linux distributions, or /usr/lib/exim/config
in
older configurations. You can find out where the configuration file is by
running the command:
$ exim -bP configure_file
You may have to edit the configuration file to reflect values specific to your site. In most common configurations there isn’t a great deal to change, and a working configuration should rarely have to be modified.
By default, Exim processes and delivers all incoming mail immediately. If you have relatively high traffic, you may instead have Exim collect all messages in the so-called queue, and process them at regular intervals only.
When handling mail within a TCP/IP network, Exim is frequently run in daemon
mode: at system boot time, it is invoked from
/etc/init.d/exim
[113]
and puts itself in the background, where it waits for incoming TCP connections
on the SMTP port (usually port 25). This is beneficial whenever you expect to
have a significant amount of traffic because Exim doesn’t have to start up
for every incoming connection. Alternatively, inetd could
manage the SMTP port and have it spawn Exim whenever there is a connection
on this port. This configuration might be useful when you have limited
memory and low mail traffic volumes.
Exim has a complicated set of command-line options, including many that match those of sendmail. Instead of trying to put together exactly the right options for your needs, you can implement the most common types of operation by invoking traditional commands like rmail or rsmtp. These are symbolic links to Exim (or if they’re not, you can easily link them to it). When you run one of the commands, Exim checks the name you used to invoke it and sets the proper options itself.
There are two links to Exim that you should have under all circumstances: /usr/bin/rmail and /usr/sbin/sendmail.[114] When you compose and send a mail message with a user agent like elm, the message is piped to sendmail or rmail for delivery, which is why both /usr/sbin/sendmail and /usr/bin/rmail should point to Exim. The list of recipients for the message is passed to Exim on the command line.[115] The same happens with mail coming in via UUCP. You can set up the required pathnames to point to Exim by typing the following at a shell prompt:
$ln -s /usr/sbin/exim /usr/bin/rmail
$ln -s /usr/sbin/exim /usr/sbin/sendmail
If you want to dig further into the details of configuring Exim, you should consult the full Exim specification. If this isn’t included in your favorite Linux distribution, you can get it from the source to Exim, or read it online from Exim’s web site at http://www.exim.org.
To run Exim, you must first decide whether you want it to handle incoming SMTP messages by running as a separate daemon, or whether to have inetd manage the SMTP port and invoke Exim only whenever an SMTP connection is requested from a client. Usually, you will prefer daemon operation on the mail server because it loads the machine far less than spawning Exim over and over again for each connection. As the mail server also delivers most incoming mail directly to the users, you should choose inetd operation on most other hosts.
Whatever mode of operation you choose for each individual host, you
have to make sure you have the following entry in your
/etc/services
file:
smtp 25/tcp # Simple Mail Transfer Protocol
This defines the TCP port number that is used for SMTP conversations. Port number 25 is the standard defined by the “Assigned Numbers” RFC (RFC-1700).
When run in daemon mode, Exim puts itself in the background and waits for
connections on the SMTP port. When a connection occurs, it forks, and the
child process conducts an SMTP conversation with the peer process on the
calling host. The Exim daemon is usually started by invoking it from the
rc
script at boot time using the following command:
/usr/sbin/exim -bd -q15m
The -bd
flag turns on daemon mode, and
-q15m
makes it process whatever messages have
accumulated in the message queue every 15 minutes.
If you want to use inetd instead, your
/etc/inetd.conf
file should contain a line like this:
smtp stream tcp nowait root /usr/sbin/exim in.exim -bs
Remember you have to make inetd re-read
inetd.conf
by sending it an
HUP
signal after
making any changes.[116]
Daemon and inetd modes are mutually exclusive. If
you run Exim in daemon mode, you should make sure to comment out any line in
inetd.conf
for the
smtp
service. Equivalently, when
having inetd manage Exim, make sure that no
rc
script starts the Exim daemon.
You can check that Exim is correctly set up for receiving incoming SMTP messages by telnetting to the SMTP port on your machine. This is what a successful connect to the SMTP server looks like:
$telnet localhost smtp
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 richard.vbrew.com ESMTP Exim 3.13 #1 Sun, 30 Jan 2000 16:23:55 +0600quit
221 richard.brew.com closing connection Connection closed by foreign host.
If this test doesn’t produce the SMTP banner (the line starting with the 220 code), check that you are either running an Exim daemon process or have inetd correctly configured. If that doesn’t reveal the problem, look in the Exim log files (described next) in case there is an error in Exim’s configuration file.
[113] Other possible locations are
/etc/rc.d/init.d
and
rc.inet2
. The latter is common on systems
using a BSD-style structure for system administration files in the
/etc
directory.
[114] This is the new standard location of sendmail according to
the Linux File System Standard. Another common location is
/usr/lib/sendmail
, which is likely to be used by mail
programs that are not specially configured for Linux.
You can define both filenames as symbolic links to
Exim so that programs and scripts invoking sendmail will instead
invoke Exim to do the same things.
[115] Some user agents, however, use the SMTP protocol to pass messages to the
transport agent, calling it with the -bs
option.
[116] Use kill HUP
pid,
for which pid
is the process ID of the inetd process retrieved from a
ps listing.
No credit card required