Configuration of sendmail V8

If you have sendmail installed on your systen chances are you have the whole 
set of sendmail configuration files. For instance, the Slackware distribution 
I have hid them in a package called smailcnf.tgz. You'll most likely find 
them in /usr/src/sendmail/cf. There should be a approx. 50KB big README which 
describes the new configuration-method for sendmail. In addition, you will 
need all the m4 macros for sendmail (which should have come with the sendmail
sources, or you can have sendmail-cf.blabla.rpm; sure other distrib schemes 
have their equivalent packages too) 

Though sendmail is controlled via an almost 20KB big configuration file
(/etc/ you don't have to write it on your own (which most of the 
people think, those who are scared of sendmail). In order to facilitate the
configuration of sendmail you will need the following m4 script, it replaces
the ugly :) It needs fnet.m4 that is included in last tx and that 
goes in ..../sendmail-cf/mailer/ and another configuration file which follows
( which goes in ....sendmail/cf/cf. 

The m4 script will create your /etc/ file from these two other 
files and a few other supporting files, which you may or may not need to 

* adds anti-spam support (add email/domains to block in /etc/sendmail.rej)
* assumess you use * domain for fidonet and *.ftn for othernets
* uses a "mailertable" database for special routings (others than internet
  smart host and FTN smart host)
* uses "revaliases" database to masquerade From: lines; putting the real
  email on them.
* uses a "private" database to redirect messages to addresses on other
  domains than yours (that is useful to avoid sending to internet mail
  write on your machine to users that are also on your machine)

Now inorder to make IFMAIL known you will need to create a file called
.....sendmail-cf/mailer/ftn.m4 with the following content:

# ....sendmail-cf/mailer/ftn.m4
# IFMAIL FTN mailer for sendmail V8
# MAILER(smtp) and MAILER(uucp) must be included!
ifdef(`FIDO_MAILER_FLAGS',, `define(`FIDO_MAILER_FLAGS', `8mDFMuSC')')
ifdef(`FIDO_MAILER_PATH',, `define(`FIDO_MAILER_PATH', /usr/lib/ifmail/ifmail)')
ifdef(`FIDO_MAILER_USER',, `define(`FIDO_MAILER_USER', `fnet:uucp')')
ifdef(`FIDO_MAILER_ARGS_H',, `define(`FIDO_MAILER_ARGS_H', `ifmail -r $h -g h $u')')
ifdef(`FIDO_MAILER_ARGS_C',, `define(`FIDO_MAILER_ARGS_C', `ifmail -r $h -g c $u')')
ifdef(`FIDO_MAILER_ARGS_B',, `define(`FIDO_MAILER_ARGS_B', `ifmail -b -r $h -g h $u')')
ifdef(`FIDO_MAILER_ARGS_P',, `define(`FIDO_MAILER_ARGS_P', `ifmail -l-3 -r $h -g h $u')')

# FIDO Mailer specification #

VERSIONID(`@(#)fnet.m4  1.01 ( 7/7/97')

# normal fnet mailer, pkt as hold

# This is for crash mail just in case you need it * USE WHITH CARE *

# This doesn't split messages when writting in pkt, of course the node
# receiving the pkt must be able to handle arbitrary size messages.
# if the other end uses ifmail too use this.

# This one uses a "kludge verbosity" of level -3, that is nothing is kept
# from usenet/email infos.

As one can see the m4 configuration file for ifmail isn't that complex, and we
don't have to care about what exactly is happening, we simply use the defined
mailer "ftn" like the predefined mailers "smtp", "uucp" etc. A simple 
definition of the ftn mailer options will be explaned later on.

Now let's go on to the next configuration file. I called it /, but 
the name isn't that relevant, what is only necessary is that it resides in 
.....sendmail/cf/cf. looks like this:

# ....sendmail/cf/cf/
# sendmail V8 configuration for
# using UUCP and IFMAIL
define(`SMART_HOST',		``[]'')
define(`FIDO_HOST_ADDRESS',	``'')
define(`FIDO_SMART_HOST',	``'')
define(`FIDO_GATEWAY',		``'')

define(`confTO_QUEUEWARN', `2d')
define(`confTO_QUEUERETURN', `8d')
FEATURE(genericstable,``hash -o /etc/revaliases'')

# Pseudo-domains (don't call the DNS on them) ftn

# Domains and addresses we refuse mail from

# for fidonet address, don't send trough fnet mailer addresses like
#,, etc
CFfidonet ns ns2 mail smtp www ftp

# email address on other domains that we redirect
Kprivate hash -o /etc/private

# private
R$+ < @ $+ > $*			$: < $(private $1 @ $2 $: $) > $1 < @ $2 > $3
R< $+ > $+ < @ $+ > $*		$@ $>97 $1
R<> $+ < @ $+ > $*		$: $1 < @ $2 > $3

# ************ FIDONET.ORG ***********
# for nodes allways put leading $* if you want to route his points too
# routed trough default smart host FIDO_SMART_HOST
R$* < @ $~F $+ . > $*	$#fnet $@ FIDO_SMART_HOST $: $1 < @ $2 $3 > $4
R$* < @ $~F $+ . > $*	$#fnet $@ FIDO_SMART_HOST $: $1 < @ $2 $3 > $4
R$* < @ $~F $+ . > $*	$#fnet $@ FIDO_SMART_HOST $: $1 < @ $2 $3 > $4
R$* < @ $~F $+ . > $*	$#fnet $@ FIDO_SMART_HOST $: $1 < @ $2 $3 > $4
R$* < @ $~F $+ . > $*	$#fnet $@ FIDO_SMART_HOST $: $1 < @ $2 $3 > $4
R$* < @ $~F $+ . > $*	$#fnet $@ FIDO_SMART_HOST $: $1 < @ $2 $3 > $4

# all the remaining FTN's (via fido smart host FIDO_SMART_HOST)
R$* < @ $+ .ftn . > $*			$#fnet $@ FIDO_SMART_HOST $: $1 < @ $2 .ftn > $3

# If you don't have internet connectivity comment out this line
# to send through the gateway FIDO_GATEWAY
# (packets will go to your default uplink FIDO_SMART_HOST)
ifdef(`USE_FGATE',`',`#')R$* < @ $* > $*			$#fnet $@ FIDO_SMART_HOST $: $1 % $2 < @ FIDO_GATEWAY > $3


R < $=R >			$#error $@ 5.7.1 $: "571 unsolicited email is refused"
R $=R				$#error $@ 5.7.1 $: "571 unsolicited email is refused"
R$*				$: $>3 $1
R $+ < @ $* $=R >		$#error $@ 5.7.1 $: "571 unsolicited email is refused"
R $+ < @ $* $=R . >		$#error $@ 5.7.1 $: "571 unsolicited email is refused"
R$*				$@ OK

#sender-address $| recipient-address
R $+ % $* @ FIDO_GATEWAY $| $*	$: $1 @ $2 $| $3
R < $+ @ $* $=R > $| $*		$#error $@ 5.7.1 $: "571 unsolicited email is refused"
R $+ @ $* $=R $| $*		$#error $@ 5.7.1 $: "571 unsolicited email is refused"
R < $=R > $| $*			$#error $@ 5.7.1 $: "571 unsolicited email is refused"
R $=R $| $*			$#error $@ 5.7.1 $: "571 unsolicited email is refused"

# To: "UUCP" at local is returned back. Because it happens with ifmail
# receiving mail to "UUCP" via FTN but whitout a To: line specifying a
# destination ! 8-)
R $* $| UUCP	$#error $: "You MUST provide a To: address"
R $* ftn $| UUCP		$#error $: "You MUST provide a To: address"

R$*				$@ OK
#    End    #

You will need to reconfigure the following lines in the file to 
reflect your systems configuration. 

define(`SMART_HOST',            ``[]'')
define(`FIDO_HOST_ADDRESS',     ``'')
define(`FIDO_SMART_HOST',       ``'')
define(`FIDO_GATEWAY',          ``'')

Here's a breif explanation of the above mailer defines.

SMART_HOST defines your ISP smart host, that is the machine you sent
	email to. That is a machine accessible by smtp (when you
	connect to the internet throug PPP do "sendmail -q" and it
	delivers the mail). enclose the name with [ ] if you are not 
	connected 24h/24h, otherwise problems will happen.
FIDO_HOST_ADDRESS is *your* fido address (can be a point address of course)
FIDO_SMART_HOST your fido uplink address, that is where you send pkt to.
FIDO_GATEWAY the fidonet -> internet gateway nearest to you
USE_FGATE this one is a little different. If you have *NO* internet
	connectivity at all, that is if you rely on the fidonet gateway,
	put this line:
	however, if you can connect to the internet to send to a smart host
	put this one instead :

After editing the file, your ready to create the file. 
Go to the directory ....sendmail/cf/cf and execute pmake The file
.....sendmail/cf/cf/obj/ should have been created. Move this file to 
/etc/ and the sendmail configuration is ready. In case pmake isn't 
installed run this instead:

m4 > /etc/

Don't forget to include in /etc/ a list of all your machine local
addresses (either uucp name if one, fidonet, other FTN,...).
Exemple I have :

# - include all aliases for your machine here.

If you are connected to other FTN networks or if you want some routing other
than trough FIDO_SMART_HOST and/or SMART_HOST edit the file /etc/mailertable
to add some special routings, using the syntax :

domain		transport:trough.system


sends direct to 2:293/2219 trough fnet. NOTE: points aren't handled, for
that you will also need:

note the leading dot !

For *your* points put (assming you are :

(again note the leading dot, and the %1)

for othernets is the same, ex:

..maxwellnet.ftn			fnet:f12.n34.z555.maxwellnet.ftn

and for other transports too:

..some.uucp			uucp-dom:barney
..some.smtp			smtp:[local.networked.machine]

each time you modify /etc/mailertable you need to recompile it running:

makemap hash /etc/mailertable < /etc/mailertable

To masquerade From: addresses edit /etc/revaliases and add lines like

localuser	login@somewhere

to masquerade the local user "localuser" as "login@somewhere".
each time you modify /etc/revaliases you need to recompile it running:

makemap hash /etc/revaliases < etc/revaliases

To redirect mail to specific users of other domains add in /etc/private
lines like:

user@domain		localuser

For exemple if you use "peter" as your login on your linux box; and
your email at your ISP is; then you can put:		peter

so if someone sends mail to it isn't sent to internet
but directly sent to local user peter.

each time you modify /etc/private you need to recompile it running:

makemap hash /etc/private < /etc/private

Here is a breif explanation of what "F=8mDFMhuSC, S=11, R=21" in
the fnet.m4 file delivery agent definition:

The F section contains the flags which describe a delivery agent's
behavior. Here is a breakdown of what your flags mean:
	8 = use 8 bit
	m = allow delivery to multiple recipients
	D = force inclusion of date information in mail header
	M = force inclusion of message identification information in mail
	F = force inclusion of sender (From) information in mail header
	h = preserve case in hostname 
	u = preserve case for username

The C flag causes sendmail to append a domain to recipients without one
(the domain of the sender. Useful when sending to someone on your own
BBS); and the S flag causes sendmail to invoke the delivery agent
(in this case ifmail) with the user and group id specified by the U=
equate. If the U= equate is missing or 0 sendmail runs the delivery agent 
as root (note: in sendmail versions prior to v8.7, there was no U= equate,
so the S flag causes sendmail to always run the delivery agent as root). 
I don't have a U= equate, so ifmail runs as root which seems to be fine for 

The S section specifies the Sender rewriting rule set, with rule 51 being 
used for the envelope and rule 31 used for the header. Finally the R section 
specifies the Recipient rewriting rule set. In this case rule set 21 is used 
for rewriting both headers and the envelope. Look around in your 
file to find these rules and see what they do.

By the way, this information comes from the book "sendmail, 2nd edition" by 
Bryan Costales and Eric Allman (who is the author of sendmail) published by 
O'Reilly & Associates (ISBN 1-56592-222-0). I strongly recommend it to anyone
who is working with sendmail. It is very thourough and well written, with many 

After successfully creating a file your now ready to create a 
mail alias-file. Without going in to great detail, mail aliasing is just 
one of sendmails powerful features which allows forwarding of mail to other
sites and users. Its not hard to adminaster. The mail sent to the person on 
the left is forwarded to the person on the right. Here's what my alias file 
looks like.    

# /etc/aliases
# compile this file by issueing the command: newaliases
nobody: /dev/null
root: gfryde01
support: gfryde01
admin: gfryde01
operator: gfryde01
postmaster: gfryde01
faxadmin: gfryde01 
usenet: gfryde01
sysop: gfryde01
uucp: gfryde01
news: gfryde01
mail: gfryde01
fnet: gfryde01
fido: gfryde01
greg_frydenlund: gfryde01
greg.frydenlund: gfryde01
gregfrydenlund: gfryde01

This file has to be compiled with the command newaliases to a database after 
any changes.  

Now to start sendmail as a daemon by entering:

/usr/sbin/sendmail -bd -q 15m

Add the above line to /etc/rc.d/rc.local. On many systems it is already defined
in /etc/rc.d/rc.M which is possible, too. Alternatively one can start sendmail
by cron, and let inetd listen to the port. For this enter the following in the
crontab of the user root:

*/20  * * * *   /usr/sbin/sendmail -q

and insert the following into your /etc/inetd.conf:

smtp  stream  tcp   nowait  root  /usr/sbin/tcpd  /usr/sbin/sendmail -bs

Don't forget to kill -HUP inetd after changing inetd.conf, to inform inetd 
about your changes.

sendmail will write its log messages via syslogd. I recommend to enter the 
following entry in /etc/syslog.conf:

mail.*                      /var/log/mail

Do not forget to restart syslogd after this change with a killall -1 as already
described in Configuration of ifcico.

# Testing sendmails rewrite rules_

Sendmail has a built-in mechanism which allows you to test the rewrite rules
found in a .cf file.  The rewrite rules we are particularly interested in are
the fidonet ones. First, you will need to startup sendmail in "test mode" 
with the following command.

sendmail -bt

Second, issue the following command at the prompt and hopefully you should see 
something simialiar the list below.

> 3,0

The last line in the list below is the one were interested in.

rewrite: ruleset   3     input: me @ f10 . n125 . z1 . fidonet . org
rewrite: ruleset  96     input: < me @ f10 . n125 . z1 . fidonet . org . >
rewrite: ruleset  96   returns: < me @ f10 . n125 . z1 . fidonet . org . >
rewrite: ruleset   3   returns: < me @ f10 . n125 . z1 . fidonet . org . >
rewrite: ruleset   0     input: < me @ f10 . n125 . z1 . fidonet . org . >
rewrite: ruleset  98     input: < me @ f10 . n125 . z1 . fidonet . org . >
rewrite: ruleset  98   returns: < me @ f10 . n125 . z1 . fidonet . org . >
rewrite: ruleset   0   returns: $# ftn $@ f33 . n125 . z1 $: me < @ f33 . n125
.. z1 . fidonet . org >
As you can see at the bottom of this list the mailer _ftn_ is called which 
is exactly what you want. I suggest you try various address (me@localhost) 
to be sure that sendmail handles all the rewrite rules appropreiatly for 
your own system.