![]()
There is a Sendmail Web page (http://www.sendmail.org), and many sites mirror the source code from there.
Extract the source into a directory — /usr/src/sendmail-x.x.xx — and change into the /src directory therein. In there is a makesendmail shell script that will do all the work for you. It is easiest to do the configuration in the source directory, before actually installing the binary and configuration files.
The Sendmail distribution includes several sample sendmail.cf files, one or other of which can be adapted to most configurations with a few changes; and any modern Linux distribution will also include these in its Sendmail installation.
Version 8 Sendmail has introduced an important simplification into the configuration process, by shifting the user intervention from direct editing of the Sendmail configuration file to making changes to files of m4(1) macros, which is easier and more intuitive. I consider use of the m4 macros in this section, whereas the section on configuring a Sendmail client that connects to our mail hub will deal with the /etc/sendmail.cf file directly, as that process is sufficiently simple to be easily accomplished without the aid of the m4 macros.
m4/
This contains support routines, which should not be changed.
cf/
The configuration files themselves. They have ".mc"
suffixes, and must be run through the Unix m4
program to become usable. The resulting output should have a
".cf" suffix.
ostype/
Definitions describing a particular operating system type.
These should always be referenced using the OSTYPE macro in the
".mc" file.
domain/
Definitions describing a particular domain, referenced using
the DOMAIN macro in the ".mc" file.
mailer/
Descriptions of mailers, referenced using the MAILER macro in
the ".mc" file.
sh/
Shell files used when building the ".cf" file from the
".mc" file in the cf/ subdirectory.
feature/
These hold special features that you might want to include.
They should be referenced using the FEATURE macro.
hack/
Local hacks from Berkeley (the home of Sendmail), of no more
than voyeuristic interest, if that.
siteconfig/
Site configuration — for instance, tables of locally
connected UUCP sites.
VERSIONID(`@(#)unixworld-online.mc 8.5 (Virtual Reality, Maan) 19/8/97')
OSTYPE(linux)
FEATURE(nouucp)
MAILER(local)
MAILER(smtp)
The first line is for housekeeping, and puts the version line into the output file so you can keep track of changes.
OSTYPE
The first macro defines our operating system. You must define an operating system environment, or the configuration file build will not work. For us, the OS is Linux, so we use the file in the ostype directory named linux.mc. This contains such things as default file locations and other OS-specific material. You shouldn't need to change it.
FEATURE
nouucp The only feature we use is nouucp, which says, don't do anything special with UUCP addresses at all.
nullclient This feature could be used to do what we will do later on by hand, that is, generate a stripped-down configuration file that does noting but forward all mail to a central hub via a local SMTP-based network. The argument is the name of that hub.
MAILER
The MAILER macros use macro files to specify rules to handle one or more mailers. Here, we invoke definitions for a local mailer and an SMTP mailer. As a general rule, put the MAILER definitions last in your .mc file, and always put MAILER(smtp) before MAILER(uucp) — several features and definitions will modify the definition of mailers, and the SMTP mailer modifies the UUCP mailer.
local The local and prog mailers. You will almost always need these; the only exception is if you relay ALL your mail to another site. This mailer is included automatically.
smtp The Simple Mail Transport Protocol mailer. This does not hide hosts behind a gateway or another other such hack; it assumes a world where everyone is running a name server. This file actually defines four mailers: smtp for regular (old-style) SMTP to other servers, esmtp for extended SMTP to other servers, smtp8 to do SMTP to other servers without converting 8-bit data to MIME (essentially, you are saying here that you know the other end is 8-bit clean even if it doesn't say so), and relay for transmission to our RELAY_HOST, LUSER_RELAY, or MAILER_HUB.
m4 ../m4/cf.m4 config.mc > config.cf
/usr/sbin/sendmail
This is the actual Sendmail program binary. There may be a
symbolic link in Sendmail's historic location,
/usr/lib, pointing here, but /usr/sbin/
is now the actual directory location.
/etc/sendmail.cf
This is the configuration file that we generated.
/usr/bin/newaliases
This is another symbolic link to
/usr/sbin/sendmail. When invoked by this name,
Sendmail will rebuild the aliases database.
/var/spool/mqueue
This is the directory, where incoming and outgoing mail
is kept awaiting delivery. It should have mode 700, to prevent
inquisitive users from peeking at other users' mail.
/etc/aliases
This is the systemwide aliases file.
/usr/lib/sendmail.hf
This is the help file for Sendmail.
/etc/sendmail.st
This optional file can be used by Sendmail to record statistics.
/usr/bin/mailq
This is also a symbolic link to
/usr/sbin/sendmail. When invoked under this name,
Sendmail prints the contents of the mail queue.
if [ -x /usr/sbin/sendmail ]
echo "sendmail "
/usr/sbin/sendmail -bd -q1h
fi
Make sure the aliases file isn't writable except by trusted system personnel. This includes both the text and database version.
Make sure that other files that Sendmail reads, such as the mailertable, are only writable by trusted system personnel.
The queue directory should definitely not be world writable. In fact, opinions vary on the correct permissions for the mail queue. One school of thought holds that 700 is the safest way; the other that 711 is permissible, allowing the queue to be searched by a Sendmail process that has relinquised its root privileges. Use 700 to be on the safe side; it will always be possible to relax this slightly should it cause problems.
bob: bob@donner.example.com
It's recommended to have the mail-hub use the Sendmail "masquerade" feature, so that the headers of mail messages originating from your private network are rewritten to look as though they came from the hub.
First, we turn on masquerading:
MASQUERADE_AS(mailhub.example.com)
MASQUERADE_DOMAIN(otherhost.example.com)
MASQUERADE_DOMAIN_FILE(filename)
The ".mc" file is simple, just:
divert(0)dnl
VERSIONID(`@(#)dumbclient.mc 28/10/97')
OSTYPE(linux)
FEATURE(nullclient, mailhost)
This case is simple enough that the /etc/sendmail.cf file is not so arcane as it can be, so it is worth taking the opportunity to examine it in detail.
There isn't the space for a full run-down on the syntax of the file. For the full story, consult the irreplaceable Sendmail book, published by O''Reilly & Associates. The file is divided into sections, not for Sendmail, but to make it easier for humans to maintain (and explain).
Sendmail "commands" are usually one-letter in length, and must be at the beginning of a line. Generally, there is no whitespace between a command letter and its arguments.
The first part, Macros, shows variables (known as "macros" in Sendmail parlance) defined by use of the "D" (Define Macro), command. All the macros defined here are explained by comments on the line preceding them — a wise practice that should not be confined to example files! eg( ### Defined Macros (1) # The name of the mail hub DRwotan.example.com # The hub as it is known to the outside world DHtiny1.demon.co.uk # The local official domain name Dj$w # Our domain name DDexample.com # Identity of the error message sender DnMailer-Daemon # Look of the Unix From line DlFrom $g $d # The characters that separate address components Do.:%@!^=/[] # Default form for the senders address Dq<$g> ') The second section, Classes, is for a special type of variable, a class, which can hold multiple values. The command letter here is "C". The class we define in this example is w, which holds a list of alternative host names for the machine (that is, other than the fully-qualified domain name, or FQDN).
### Defined Classes (2)
# All possible names for local machine
Cw localhost donner
# default delivery mode (in background)
Odbackground
# temporary file permissions-—0600 for secure mail
OF0600
# default UID & GID
Ou1
Og1
# level at which to syslog errors
OL9
# Wait for SMTP replies.
Or1h
# default messages to old style
OoTrue
# Replace unquoted spaces with a dot
OB.
### Header Declarations (4)
HFrom: $q
HReceived: by $j id $i; $b
H?x?Full-Name: $?x$x$.
H?D?Date: $a
H?M?Message-Id: <$t.$i@$j>
### Priorities (5)
Pspecial-delivery=100
Pfirst-class=0
Plist=-30
Pbulk=-60
Pjunk=-100
### Mailer Delivery Agent Definitions (6)
# Mailer to forward all mail to the hub machine
Mhub, P=[IPC], S=10, R=0, F=xmDFMuCX, A=IPC $h
# Sendmail requires these, but we wont use them
Mlocal
### The Rules Sets (7)
S0 select delivery agent
R@$+ $#error $: Missing user name
R$+ $#hub $@$R $:$1 forward to hub
<p>
S3 preprocessing for all rule sets
R$*<>$* $n handle <> error addresses
R$*<$*<$*>$*>$* $2<$3>$4 de-nest brackets
R$*<$*>$* $2 basic RFC822 parsing
S10 rewrite the sender for the hub
R$- $@$1@$H user -> user@hub
R$-@$w $@$1@$H user@local -> user@hub
R$-@$=w $@$1@$H user@othernames -> user@hub
R$-@$=w.$D $@$1@$H user@domain -> user@hub
S1 dummy ruleset 1 (unused)
The entry in /etc/services should be as follows:
pop-2 109/tcp # PostOffice V.2
pop-3 110/tcp # PostOffice V.3
pop-2 stream tcp nowait root /sbin/tcpd /usr/sbin/in.pop3d
pop-3 stream tcp nowait root /sbin/tcpd /usr/sbin/in.pop3d
I use Eudora Lite, which is a freeware, stripped-down version of Eudora Pro. It is a fine e-mail client in its own right, available from Qualcomm. Setting it up is simply a matter of pointing it at the mail hub, telling it the POP user name and password. One glitch I found was that not all options are saved to the EUDORA.INI file. Specifically, I had to set "UseWinSock=1" and "UseDialup=0" by editing the "ini" file, as changing these options from the menu had no effect.
In the section above on configuring a Linux client for the local network, I have gone into more detail, which should suffice to give you a general understanding of the file syntax. Here, I will presume that there is already a suitable sendmail.cf on the machine (provided either by the Linux distribution, or from the Sendmail sources).
The "w" macro contains any other names that this host is known by, besides the FQDN. So, if the machine is known to your ISP as example1.com, say, but to your local network as example2.com, you need to put example2.com here. You might as well put "localhost" here, too.
Cwlocalhost example2.com
DSpost.demon.co.uk
O DeliveryMode=deferred
Paul Dunne 1997
Copyright © 1995-2007
Paul Dunne,
Sponsored links (requires javascript):