A Simple Configuration of Exim

Oohara Yuuma

oohara@libra.interq.or.jp

Revision History
Revision v0.5Fri, 7 Sep 2001Revised by: oohara
Added "Running Exim as a daemon" section.
Revision v0.4Tue, 7 Aug 2001Revised by: oohara
Added fetchmail in section 1, an explanation of "byname" in section 4, and a reference to BTS in section 5.
Revision v0.3Sat, 28 Jul 2001Revised by: oohara
Now this is a part of the Newbiedoc project. Added a new section, "Finding More Info". Divided section 4 into 2 subsections.
Revision v0.2Fri, 27 Jul 2001Revised by: oohara
Fixed broken link. Reduced hand-hacking in section 4.
Revision v0.1Thu, 26 Jul 2001Revised by: oohara
This is the initial draft.

Table of Contents
1. What is Exim?
2. Assumptions
3. Very simple configuration: local only
4. A bit more advanced configuration: relay to the ISP's SMTP server
4.1. First step
4.2. Tweaking configuration files
5. Running Exim as a daemon
6. Finding more info

1. What is Exim?

Exim is a mail transport agent (MTA). With Exim, you can:


2. Assumptions

This document assumes that:


3. Very simple configuration: local only

This section describes how to configure Exim to local use only --- only e-mails from your machine to a user on your machine are accepted.

The package "exim" comes with an useful tool to configure Exim, that is, eximconfig. Do as root:
# eximconfig

Then you will see the following message.
I can do some automatic configuration of your mail system, by asking
you a number of questions.  Later you may have to confirm and/or correct
your answers. In any case, comprehensive information on configuring exim is
in the eximdoc package and in /usr/doc/exim/spec.txt
[---Press return---]
Just press return.

==============================================================================
You must choose one of the options below:

 (1) Internet site; mail is sent and received directly using SMTP. If your
     needs don't fit neatly into any category, you probably want to start
     with this one and then edit the config file by hand.

 (2) Internet site using smarthost: You receive Internet mail on this 
     machine, either directly by SMTP or by running a utility such as 
     fetchmail. Outgoing mail is sent using a smarthost. optionally with
     addresses rewritten. This is probably what you want for a dialup
     system.

 (3) Satellite system: All mail is sent to another machine, called a "smart 
     host" for delivery. root and postmaster mail is delivered according 
     to /etc/aliases. No mail is received locally.

 (4) Local delivery only: You are not on a network.  Mail for local users 
     is delivered.

 (5) No configuration: No configuration will be done now; your mail system 
     will be broken and should not be used. You must then do the 
     configuration yourself later or run this script, /usr/sbin/eximconfig, 
     as root. Look in /usr/share/doc/exim/example.conf.gz

Select a number from 1 to 5, from the list above.
Enter value (default=`1', `x' to restart):
Choose 4.

Names are spice:localhost!

==============================================================================
Mail for the `postmaster' and `root' accounts is usually redirected
to one or more user accounts, of the actual system administrators.
By default, I'll set things up so that mail for `postmaster' and for
various system accounts is redirected to `root', and mail for `root'
is redirected to a real user.  This can be changed by editing /etc/aliases.

Note that postmaster-mail should usually be read on the system it is
directed to, rather than being forwarded elsewhere, so (at least one of)
the users you choose should not redirect their mail off this machine.

Which user account(s) should system administrator mail go to ?
Enter one or more usernames separated by spaces or commas .  Enter
`none' if you want to leave this mail in `root's mailbox - NB this
is strongly discouraged.  Also, note that usernames should be lowercase!
Enter value (`x' to restart): 
The name "spice" will be the hostname of your machine. (You can see it in /etc/hostname .) Enter your account name on your machine as a normal user (not "root").

The following configuration has been entered:

==============================================================================
Mail generated on this system will have `spice' used
as the domain part (after the @) in the From: field and similar places.

The following domain(s) will be recognised as referring to this system:
 spice, localhost

Mail for postmaster, root, etc. will be sent to oohara.

Local mail is delivered.


Is this OK ?  Hit Return or type `y' to confirm it and install,
or `n' to make changes (in which case we'll go round again, giving you
your previous answers as defaults.     (Y/n) 
The name "oohara" will be your account name as a normal user. Press return. That's all!


4. A bit more advanced configuration: relay to the ISP's SMTP server

Logically, you don't need an internet service provider (ISP) to send an e-mail to yourself --- you are here. Exim can deal with e-mails properly in such cases. In other words:


4.1. First step

Let's use eximconfig again, as root.
# eximconfig

You already have an exim configuration. Continuing with eximconfig
will overwrite it. It will not keep any local modifications you have made.
If that is not your intention, you should break out now. If you do continue,
then your existing file will be renamed with .O on the end.
[---Press return---]
Press return. If you finish installing a new /etc/exim.conf , the old /etc/exim.conf will be saved as /etc/exim.conf.O . Note that the /etc/exim.conf.O will be deleted during the next eximconfig run. If you have added special features to the old /etc/exim.conf , you will need to merge it to the new /etc/exim.conf by hand. (See Tweaking Configuration Files for more details.) If you want to break out, press Ctrl + c . In this case the old /etc/exim.conf will remain untouched.

==============================================================================
You must choose one of the options below:

 (1) Internet site; mail is sent and received directly using SMTP. If your
     needs don't fit neatly into any category, you probably want to start
     with this one and then edit the config file by hand.

 (2) Internet site using smarthost: You receive Internet mail on this 
     machine, either directly by SMTP or by running a utility such as 
     fetchmail. Outgoing mail is sent using a smarthost. optionally with
     addresses rewritten. This is probably what you want for a dialup
     system.

 (3) Satellite system: All mail is sent to another machine, called a "smart 
     host" for delivery. root and postmaster mail is delivered according 
     to /etc/aliases. No mail is received locally.

 (4) Local delivery only: You are not on a network.  Mail for local users 
     is delivered.

 (5) No configuration: No configuration will be done now; your mail system 
     will be broken and should not be used. You must then do the 
     configuration yourself later or run this script, /usr/sbin/eximconfig, 
     as root. Look in /usr/share/doc/exim/example.conf.gz

Select a number from 1 to 5, from the list above.
Enter value (default=`1', `x' to restart):
Choose 2.

==============================================================================
What is the `visible' mail name of your system? This will appear on 
From: lines of outgoing messages.
Enter value (default=`spice', `x' to restart): 
Press return to select the default, that is, the host name of your machine. (You can see it in /etc/hostname .) If it must not be a visible mail name (for example, "spice" --- "oohara@spice" is an invalid mail address for the outside of my machine), don't worry --- Exim can rewrite e-mail addresses in the header of e-mails.

==============================================================================
Does this system have any other names which may appear on incoming
mail messages, apart from the visible name above (spice) and
localhost?

By default all domains will be treated the same; if you want different 
domain names to be treated differently, you will need to edit the config 
file afterwards: see the documentation for the "domains" director 
option.

If there are any more, enter them here, separated with spaces or commas.  
If there are none, say `none'.
Enter value (default=`none', `x' to restart): 
Of course, the name "spice" will be the host name of your machine. Press return.

==============================================================================
All mail from here or specified other local machines to anywhere on
the internet will be accepted, as will mail from anywhere on the 
internet to here. 

Are there any domains you want to relay mail for---that is, you are 
prepared to accept mail for them from anywhere on the internet, but
they are not local domains.

If there are any, enter them here, separated with spaces or commas. You
can use wildcards. If there are none, say `none'. If you want to relay 
mail for all domains that specify you as an MX, then say `mx'
Enter value (default=`none', `x' to restart): 
Press return.

==============================================================================
Obviously, any machines that use us as a smarthost have to be excluded
from the relaying controls, as using us to relay mail for them is the
whole point.

Are there any networks of local machines you want to relay mail for?

If there are any, enter them here, separated with spaces or commas. You
should use the standard address/length format (e.g. 194.222.242.0/24)
If there are none, say `none'.

You need to double the colons in IPv6 addreses (e.g. 5f03::1200::836f::::/48)
Enter value (default=`none', `x' to restart): 
Press return.

==============================================================================
You may want to filter out unsolicited commercial email, (UCE, also known 
as spam). Unfortunately it is difficult keeping up with all the spamming 
sites and abused relays.

The Realtime Blackhole List is a spam filter that someone else maintains
(see http://maps.vix.com/rbl/). They are very quick to add sites, so
if you bounce on this you may occasionally miss legitimate mail. Adding
a header is an alternative---then individual users can choose what to do 
with RBL mail using their personal filter files.
 
Note that the RBL only works if you receive mail directly. If it is stored
for you at your ISP, the RBL won't work as it depends on the IP address the
connection comes from.

Would you like to use the RBL? ('f'ilter, 'r'eject, or 'n'o)?
Enter value (default=`n', `x' to restart): 
Press return.

==============================================================================
Which machine will act as the smarthost and handle outgoing mail?

Enter value (`x' to restart): 
Enter the name (not IP address) of the SMTP (simple mail transfer protocol) server of your internet service provider (ISP). Here I use a fictitious example, that is, fake.smtp.server .

Names are localhost:spice!

==============================================================================
Mail for the `postmaster' and `root' accounts is usually redirected
to one or more user accounts, of the actual system administrators.
By default, I'll set things up so that mail for `postmaster' and for
various system accounts is redirected to `root', and mail for `root'
is redirected to a real user.  This can be changed by editing /etc/aliases.

Note that postmaster-mail should usually be read on the system it is
directed to, rather than being forwarded elsewhere, so (at least one of)
the users you choose should not redirect their mail off this machine.

Which user account(s) should system administrator mail go to ?
Enter one or more usernames separated by spaces or commas .  Enter
`none' if you want to leave this mail in `root's mailbox - NB this
is strongly discouraged.  Also, note that usernames should be lowercase!
Enter value (`x' to restart): 
Again, the name "spice" will be the host name of your machine. Enter your account name on your machine as a normal user (not "root").

==============================================================================
You already have an /etc/aliases file. Do you want to replace this with
a new one (the old one will be kept and renamed to aliases.O)? (y/n)
Enter value (default=`y', `x' to restart): 
Press return.

The following configuration has been entered:

==============================================================================
Mail generated on this system will have `spice' used
as the domain part (after the @) in the From: field and similar places.

The following domain(s) will be recognised as referring to this system:
 localhost, spice

Mail for postmaster, root, etc. will be sent to oohara.

Local mail is delivered.

Outbound remote mail is sent via fake.smtp.server.


Is this OK ?  Hit Return or type `y' to confirm it and install,
or `n' to make changes (in which case we'll go round again, giving you
your previous answers as defaults.     (Y/n) 
Press return.

Then, you must edit /etc/email-addresses by hand (as root). This is necessary for rewriting e-mail addresses in the header of e-mails.
# This file contains email addresses to use for outgoing mail. Any local
# part not in here will be qualified by the system domain as normal.
#
# It should contain lines of the form:
#
#user: someone@isp.com
#otheruser: someoneelse@anotherisp.com
Add your account name on your machine as a normal user and the "real" e-mail address (that is, an e-mail address given by your internet service provider (ISP)), separating by a colon. For example,
# This file contains email addresses to use for outgoing mail. Any local
# part not in here will be qualified by the system domain as normal.
#
# It should contain lines of the form:
#
#user: someone@isp.com
#otheruser: someoneelse@anotherisp.com
oohara: oohara@libra.interq.or.jp

That's all. Congratulations!. Try sending an e-mail to yourself without internet connection. Use "USERNAME@localhost" as a To: address, replacing USERNAME with your account name on your machine. (You may omit the "@localhost" part.) You can check the header of the e-mail to ensure that it didn't go outside of your machine.


4.2. Tweaking configuration files

Note that editing /etc/exim.conf must be done by root.


5. Running Exim as a daemon

On a Debian system, Exim will run from inetd (8). This is dangerous because an attacker can stop Exim working by opening many (100 will be enough) connections to it, preventing it to handle any more connection.

You can avoid this attack by running Exim as a daemon. Edit the file /etc/inetd.conf as root.
#:MAIL: Mail, news and uucp services.
smtp           stream  tcp     nowait  mail    /usr/sbin/exim exim -bs
Add # to the "smtp" line.
#:MAIL: Mail, news and uucp services.
#smtp           stream  tcp     nowait  mail    /usr/sbin/exim exim -bs
Then Exim will run as a daemon when you boot the system next time. To run Exim as a daemon without reboot, do as root:
# /etc/init.d/exim start


6. Finding more info

If you want to know how to use the command "exim", see the manual page.
$ man exim

For a deadly serious user who wants to know everything about Exim, a complete specification of Exim is available. Install exim-doc-html with this command (as root)
# apt-get install exim-doc-html
and see /usr/share/doc/exim/manual.html/spec_toc.html with your favorite web browser.

The Exim Home Page (http://www.exim.org) is also available.

If something is wrong with exim, it may be one of the known bugs.