How To Setup A Linux Mail Hub
How To Setup A Linux Mail Hub
How To Set Up A
Linux Mail Hub
A mail hub is a machine that sits on your LAN, acting as the interface between your users and the
Internet. It processes all mail, ensuring that messages sent from users get transmitted and that
incoming items are distributed to the correct user. Linux, the free version of Unix, allows you to
set up a Unix-based mail hub on an old Intel box for minimum outlay and maximum flexibility.
By Paul Dunne
information, see the README in the with UUCP addresses at all”. local and prog mailers. You will almost
cf/ subdirectory. There’s another feature, nullclient. always need these; the only exception
This could be used to do what we will is if you relay all your mail to another
VERSIONID(’@(#)yourcompany.mc do later on by hand, ie, generate a site. This mailer is included automat-
8.5 (Berks) 10/8/97’) stripped-down configuration file that ically.
OSTYPE(mklinux) FEATURE(nouucp) does nothing but forward all mail to a SMTP is the Simple Mail Transport
MAILER(local) MAILER(smtp) central hub via a local SMTP-based Protocol mailer. This does not hide
network. The argument is the name of hosts behind a gateway or another
The first line is for housekeeping, that hub. other such hack; it assumes a world
and puts the version line into the out- where everyone is running the name
put file, so you can keep track of changes. MAILER server. This file actually defines four
The MAILER macros use macro mailers: “smtp” for regular (old-style)
OSTYPE files to specify rules to handle one or SMTP to other servers, “esmtp” for ex-
The first macro defines our operat- more mailers. Here, we invoke defini- tended SMTP to other servers, “smtp8"
ing system. You must define an oper- tions for a local mailer and an SMTP to do SMTP to other servers without
ating system environment, or the mailer. There are fewer mailers sup- converting 8-bit data to MIME (essen-
configuration file build will fail. For us, ported in this version than the pre- tially, this is your statement that you
the OS is of course Linux; we use the vious version, owing mostly to a know the other end is 8-bit clean even
file in ostypes called mklinux.mc. This simpler world. As a general rule, put if it doesn’t say so), and ”relay” for
contains details such as default file lo- the MAILER definitions last in your transmission to our RELAY_HOST,
cations and other OS-specific material. .mc file, and always put MAILER- LUSER_RELAY or MAILER_HUB.
It should not need to be changed. (smtp) before MAILER(uucp) - several
features and definitions will modify sendmail.cf
FEATURE the definition of mailers, and the SMTP The final sendmail configuration
The only feature we use is nouucp, mailer modifies the UUCP mailer. file is produced by invoking M4 with
which says “don’t do anything special The “local” parameter specifies the the .mc file given above as its argu-
File: T1402.2
PC Network Advisor Issue 89 (November 1997) Page 16
Tutorial:Hardware
ment. The command looks like this: Starting Sendmail deserved, particularly with version 8,
which solved a lot of the problems that
m4 m4/cf.m4 config.mc > config.cf You will most likely want to have previous versions did have. Much of
the sendmail daemon started every sendmail’s security is down to the sys-
where config.mc is the macro file time the machine boots up. This is tem administrator. Some specific
we’ve developed above, and config.cf done by adding a line to the appropri- points to watch for are:
the output - the sendmail configura- ate rc file in /etc/rc.d. The exact con-
tion file - which will end up as figuration of /etc/rc.d varies between ● Make sure the aliases file isn’t wri-
/etc/sendmail.cf. Linux distributions (I suppose if you table except by trusted system per-
are conservative, you may just have a sonnel. This includes both the text
simple BSD-style set-up, with only and database version.
A Sendmail Installation /etc/rc and /etc/rc.local), so I can’t ● Make sure that other files that send-
Having completed the configura- give exact instructions that are guaran- mail reads, such as the mailertable,
tion, log in as root and type “make teed to be applicable. The easiest thing are only writable by trusted system
install” to install the new sendmail - is probably to put it in /etc/rc.d/rc.lo- personnel.
having remembered to back up your cal. The line should look like this: ● The queue directory should not be
old program in case anything should world writable.
if [ -x /usr/sbin/sendmail ]
be out of order. The following are the
echo “sendmail”
files installed by sendmail. /usr/sbin/sendmail -bd -q1h Clients
fi
/usr/sbin/sendmail Providing email service to other
This is the actual sendmail pro- machines in the network can be done
This checks to see if the file is there,
gram. There may be a symbolic link in in two ways. The first is to use SMTP
then tells the system console what it’s
sendmail’s historic location, /usr/lib, to act as a mail hub that sends and
doing, and starts up sendmail in
pointing here, but /usr/sbin/ is now receives Internet (and optionally local)
daemon mode (-bd), and sets it to proc-
the actual location. mail on behalf of the other machines.
ess the mail queue every hour (-q1h).
Secondly, a POP service can be set up,
/etc/sendmail.cf where local users use client software
This is the configuration file that we The Mail Queue on their computers to collect their mail
generated. via the POP3 protocol, and send mail
The mail queue lives in /var/spool-
via SMTP to the server.
/usr/bin/newaliases /mqueue (unless you have changed
the default, which you really should
This is a symbolic link to /etc/aliases
not). All mail messages are held as two
/usr/sbin/sendmail. When invoked
files here, one file being named
by this name, sendmail will rebuild the Users on the local network must be
dfXXXnnnnn, the other qfXXXnnnnn,
aliases database. identifiable by the sendmail process
where XXX is a three-letter sequence,
running on the server machine. In the
/var/spool/mqueue nnnnn a five-number sequence, both
case of POP mailboxes, this is done by
being used simply to give every mes-
This is the post office, where in-go- creating a normal user account. In the
sage a unique identifier. The qf file is
ing and outgoing mail is kept awaiting case of Linux clients collecting mail
the queue control file, containing the
delivery. It should have mode 700, to through sendmail themselves, this is
email message header and various
prevent inquisitive users from peeking done by adding the appropriate alias
processing information; the df file is
at other users’ mail. to /etc/aliases. For example, on my
the data file, and contains the body of
local network, any mail arriving at my
/etc/aliases the email message. There are other
mail server (tiny1.demon.co.uk) for
files, but they are transient and usually
This is the systemwide aliases file. “bob” is sent on to [email protected]
of interest only to sendmail.
dunne.com on my Internet network by
/usr/lib/sendmail.hf the following line in /etc/aliases:
This is the help file for sendmail. Logging
bob: [email protected]
/etc/sendmail.st Sendmail uses the syslog(8) facility.
Usually, this is set up to log all send-
This optional file can be used by The simplest way to make sure that
mail messages to /var/log/maillog,
sendmail to record statistics. mail comes back to the right place is to
which by default will record all mail
set the Reply-To header in all outgoing
/usr/bin/mailq that passes through sendmail.
mail to point to the account on the mail
This is a symbolic link to hub, not the originating machine. This
/usr/sbin/sendmail. When invoked Security can be done in the options settings of
under this name, sendmail prints the your POP3 mailer, or will be handled
Sendmail has a reputation as a secu-
contents of the mail queue. for you by sendmail on a Linux client.
rity nightmare, but this is largely un-
The Sendmail.cf File W, which holds a list of alternative host The seventh part is the heart of
names for the machine (that is, other sendmail, the rule sets. These define
Now, let’s examine the sendmail.cf than the FQDN). the re-writing of addresses. The basic
file itself - it’s listed in Figure 1. This file The third section specifies sendmail idea here is that there are two sides, a
can be kept quite simple when its only options. These can be given on the right-hand side and a left-hand side,
task is to relay all mail to another ma- command line, but as there are rather where the RHS is a pattern to match
chine for further processing. Here is a a lot, it makes more sense to have them against input, and the LHS is the trans-
minimal sendmail.cf file for installing in the file. formation to effect upon the input if a
on Linux boxes that talk to the mail The fourth part specifies what match is made. LHS and RHS are sepa-
hub. There isn’t the space for a full headers must be in every mail mes- rated by tabs; comments are in the
run-down on the syntax of the file. For sage. These are the headers that send- third column.
the full gen, consult the irreplaceable mail will add if the MUA has not
book Sendmail, published by O’Reilly already done so.
& Associates.
Windows
The fifth section is a set of priority
Sendmail commands are usually settings. Sendmail will by default proc- Under Windows I use Eudora Lite,
one letter in length, and must be at the ess the mail in its queue in order of which is a freeware, cut-down version
beginning of a line. Generally, there is decreasing priority, beginning with of Eudora Pro. It is a fine email client
no space between a command and its “special-delivery”. The level of prior- in its own right and is available from
arguments. ity is set by the MUA with the “Prece- www.qualcomm.com. Setting it up is
The first part, Macros, shows vari- dence:” header. simply a matter of pointing it at the
ables (macros in sendmail parlance) The sixth section defines a set of mail hub, then telling it the POP user
being defined by use of the D, Define mailers that sendmail will use to actu- name and password. One glitch I
Macro, command. All the macros de- ally deliver mail. Remember, sendmail found was that not all options are
fined here are explained by comments is a Mail Transport Agent - it doesn’t saved to EUDORA.INI. Specifically, I
on the line before them - a wise practise do the delivery itself. These lines all had to set UseWinSock=1 and
which should not be confined to exam- begin with M. Local and prog are man- UseDialup=0 by editing the ini file, as
ple files. datory. The real work here is done by changing these options from the menu
The second section, Classes, is for a the special mailer [IPC], which invokes had no effect.
special type of variable, a class, that can internal sendmail routines rather than
hold multiple values. The command an external mailer program, to send all
here is C. The class we are defining is mail to a “smart host” using SMTP.
File: T1402.4
PC Network Advisor Issue 89 (November 1997) Page 18
Recent Reviews from Tech Support Alert