.TH smail "" "" Command
.PC "Route mail to another user"
\fBsmail [\-AcdLlRrv] \-a \fIaliasfile\fB \-F \fIaddress\fB \-H [\fIhostdomain\^\fB] \e
	\-h [\fIhost\fB] \-m \fInum\fB \-n [\fInamelist\^\fB] \-p \fIpathfile\fB \e
	\-q \fInum\fB \-u \fIuuxflags \fIaddress ...\fR
.PP
.HS
.SH Options:
.IC \fB\-A\fR
Print the resolved \*(UU addresses; do not collect mail
.IC "\fB\-a \fIaliasfile\fR"
Read \fIaliasfile\fR instead of
.B /usr/lib/mail/aliases
.IC \fB\-c\fR
Check \fB/usr/lib/mail/paths\fR
for the cost of mailing a message to a given host
.IC \fB\-d\fR
Give a verbose description; do not invoke other mailers
.IC "\fB\-F \fIaddress\fR"
Use \fIaddress\fR on the \fBFrom:\fR line
.IC "\fB\-H \fIhostdomain\fR"
Set the host's domain
.IC "\fB\-h \fIhostname\fR"
Set a \fIhostname\fR
.IC \fB\-L\fR
Send all addresses to the local mailer \fBlmail\fR for processing
.IC \fB\-l\fR
Send a domain address to the local mailer \fBlmail\fR for processing
.IC "\fB\-m \fInum\fR"
Send no more than \fInum\fR jobs to \fBuux\fR
.IC "\fB\-n [\fInamelist\^\fB]\fR"
Use name-list style aliasing
.IC "\fB\-p \fIpathfile\fR"
Read \fIpathfile\fR instead of \fB/usr/lib/mail/paths\fR
.IC "\fB\-q \fInum\fR"
Set the queuing threshold to \fInum\fR
.IC \fB\-R\fR
Reroute \*(UU paths
.IC \fB\-r\fR
Route the first component of a \*(UU path
in addition to routing domain addresses
.IC "\fB\-u \fIuuxflags\fR"
Pass \fIuuxflags\fR to \fBuux\fR
.IC \fB\-v\fR
Give verbose description, but invoke other mailers
.HE
.B smail
routes mail for delivery, either on your local system or on remote systems.
.SH Options
.B smail
recognizes the following command-line options:
.IP \fB\-A\fR 0.3i
Print the resolved \*(UU addresses.
Do not collect a message or mail anything.
.IP
Use this option
to help debug how
.B smail
resolves a \*(UU address; please note, however, that
it is only moderately helpful.
It expand all aliases and expands the route to any machine
it knows how to reach; but
it does
.I not
expand addresses that would be passed to the smart-host.
.IP "\fB\-a \fIaliasfile\fR"
Read
.I aliasfile
instead of
.B /usr/lib/mail/aliases
to find the list of mailing aliases that you have set.
.B smail
reads
.B $HOME/.aliases
regardless of whether you use this option.
.IP \fB\-c\fR
Check
.B /usr/lib/mail/paths
for the cost of mailing a message to a given host; but do not send the message.
If you wish, you can redesign the path or reset the queueing threshold.
.IP \fB\-d\fR
Tell
.B smail
to give a verbose description of what it is doing.
Do not invoke other mailers.
.IP "\fB\-F \fIaddress\fR"
Use
.I address
on the
.B From:
line in locally generated mail.
This lets you make a message appear as if it came from someone else.
.IP "\fB\-H \fIhostdomain\fR"
Set the host's domain.
The default is the contents of
.BR /etc/domain .
.IP "\fB\-h \fIhostname\fR"
Identify your system as being named
.IR hostname .
Use this option only if you wish to lie to
.B smail
about your machine's name.
By default,
.B smail
assembles your system's name from the contents of file
.BR /etc/uucpname ,
followed by a period, followed by the contents of file
.BR /etc/domain .
.IP \fB\-L\fR
Send all mail to the local mailer
.B lmail
for processing,
including mail that appears to be addressed to remote systems.
.IP \fB\-l\fR
Send all mail with a domain address (e.g., an address that includes an `@')
to the local mailer
.B lmail
for processing.
.B lmail
normally handles only mail that has a local address \(em that is, only
the name of a user, or the name of a user plus the name of your system.
.IP "\fB\-m \fInumber\fR"
Tell
.B smail
to hand no more than
.I number
jobs to
.B uux
at one time.
.IP "\fB\-n [\fInamelist\^\fB]\fR"
Use name-list style aliasing.
In this method, the name of a user is linked to an address.
This correctly resolves addresses like \fBSanta.Claus\fR.
If no
.I namelist
is named, then
.B smail
reads
.B /usr/lib/mail/fullnames
by default.
.II fullnames
.II /usr/lib/mail/fullnames
Note, too, that if
.B /usr/lib/mail/fullnames
exists,
.B smail
turns on this option by default.
.sp \n(pDu
.II mkfnames
To generate a name-list data base
for all users on your system, run the command:
.DM
	mkfnames > /usr/lib/mail/fullnames
.DE
.sp \n(pDu
This generates the list based on the contents
.BR /etc/passwd .
.II nptx
If you wish
to add other entries to your name-list database, use the command
.BR nptx .
.IP "\fB\-p \fIpathfile\fR"
Read
.I pathfile
instead of file
.B /usr/lib/mail/paths
to find the paths to other systems.
.IP "\fB\-q \fInumber\fR"
Set the queuing threshold to
.IR number .
.II paths
.II /usr/lib/mail/paths
When routing mail
to a given host,
.B smail
reads file
.B /usr/lib/mail/paths
to find the ``cost'' of contacting that host.
If the cost is less than the queueing threshold, then
.B smail
sends the mail immediately; otherwise, it queues the mail for later
shipment \(em usually when your system routinely polls (or is polled by)
that remote system.
Under \*(CO, the default queueing threshold is 100.
.IP \fB\-R\fR
Reroute \*(UU paths, trying successively larger right-hand substrings
of a path until a component is recognized.
This is called ``reroute'' routing.
.IP \fB\-r\fR
Route the first component of a \*(UU path (\fBhost!address\fR)
as well as routing domain addresses (\fBuser@domain\fR).
This is called ``always'' routing.
.IP "\fB\-u \fIuuxflags\fR"
Pass
.I uuxflags
to
.B uux
for remote mail.
This overrides any of the default values and other queueing strategies.
.IP \fB\-v\fR
Tell
.B smail
to describe verbosely what it describes.
.SH "Addressing under smail"
.B smail
understands domain-style addresses (e.g.,
.BR henry@mwc.com )
\*(UU-style path names,
(e.g.,
.BR mwc!lepanto!henry ),
and local addresses (e.g.,
.BR henry ).
.B smail
assumes that \fIuser\^\fB@\fIdomain\fR is a domain address,
assumes that \fIhost\^\fB!\fIaddress\fR is a \*(UU path,
and anything else is a local address.
.PP
When it parses a mixed address (that is, an address that contains both a
`!' and a `@'),
.B smail
gives precedence to `@' over `!'.
Thus, it parses the address
.B a!b@c
as
.BR (a!b)@c ,
rather than
.B a!(b@c) .
In practical terms, this rule means that mail addressed to
.B a!b@c
is forwarded to system
.B c
instead of to system
.BR a .
.SH "Resolving Addresses"
An e-mail address has two forms:
internal and external.
The
.I internal
form of an address is what appears on the
.B To:
line in the message's header.
This is the recipient's address as typed by the person who mailed the message.
This is regardless of whether the sender typed the recipient's full
address, or typed an alias for the recipient.
(For details on how to use aliases to address mail messages, see the Lexicon
entry for
.BR aliases .)
.II envelope
The
.I external
form of an address (also called the message's
.IR envelope ),
is the address that
.B smail
passes to the mail-delivery agent (either
.B uux
or
.BR lmail ).
.PP
.I Resolving
is the act of transforming an internal address into an envelope.
It has two stages:
host resolution and alias resolution.
.II "mail^routing"
.I "Host resolution"
(also called
.IR routing )
is how
.B smail
figures out which computer to send the message.
If
.B smail
determines that the message should be delivered on the local machine,
it then applies
.I "alias resolution"
(also called \fIalias expansion\^\fR)
to the address.
If the address proves to be an alias,
.B smail
expands the alias and again performs host resolution to find the
machine to which it should deliver the message.
If, however, if the address names a user on the local machine, then
.B smail
hands the message to the local mailer
.B lmail
for delivery.
.PP
Although
.B smail
understands domain-style addresses (i.e., addresses that contain a `@'
and are read from right to left), it can deliver mail only to \*(UU paths
(i.e., addresses that contain `!' characters and are read from left to
right) and local addresses.
Thus, it must resolve a domain address into a \*(UU path or local address.
.PP
To resolve a domain-style address,
.B smail
must find the route to the most specific part of the domain,
as specified in the routing file
.BR /usr/lib/mail/paths .
Two degrees of resolution can occur:
.IP "\fIFull Resolution\fR"
.B smail
finds the full route to the machine.
In this case,
.B smail
either tacks the user specification onto the end of the machine's \*(UU path,
or resolves it into a local address, whichever is appropriate.
.IP "\fIPartial Resolution\fR"
.B smail
finds a route for only the right portion of the domain specification;
e.g., for
.DM
	henry@lepanto.mwc.com
.DE
.IP
it finds
.B mwc.com
but cannot identify
.BR lepanto .
Here,
.B smail
tacks the complete address (in the form \fBdomain!user\fR) onto the end of the
\*(UU path.
For example, if
.B smail
finds that the route to
.B mwc.com
is via systems
.BR foo ,
.BR bar ,
and
.BR baz ,
it constructs the path:
.DM
	foo!bar!baz!lepanto.mwc.com!henry
.DE
.IP
This assumes that routing program on system
.B baz
(perhaps
.BR smail ,
perhaps some other program)
will recognize the token
.B lepanto.mwc.com
as being a domain rather than a host.
.PP
It is an error to route a partially resolved address to the local host
(a null \*(UU path), because the local host is responsible for resolving
the address more fully.
.PP
The command-line option
.B \-r
tells
.B smail
to attempt to route the first (leftmost) component of a \*(UU path,
regardless of whether it knows how to send mail directly to a site
named further to the right in the path.
This is called
.IR "always routing" .
For example, if a mail message is address to
.DM
	foo!bar!baz!mwc!lepanto!fred
.DE
.PP
option
.B \-r
tells
.B smail
always to route the mail to
.BR foo ,
even if also knows how to route mail to
.BR mwc .
.PP
The command-line option
.B \-R
tells
.B smail
to route mail to the rightmost host named on a \*(UU path.
This is called
.IR "reroute routing" .
Use it if you have a very up-to-date routing table, and wish
to bypass some obsolete routing information in the current path.
.PP
If file
.B /usr/lib/mail/paths
does not contain a path to the remote system,
.B smail
forwards mail to the the host named in the entry
.BR smart_path
in file
.BR /usr/lib/mail/config .
This lets your system depend on another,
better informed, system to deliver your mail.
Note that before you name another system as your system's
.BR smart_path ,
you should get the permission of the person who administers that system.
If you start forwarding mail to a system without permission,
that system's administrator may forward your mail to the bit bucket.
.PP
After
.B smail
resolves an address,
it reparses it to see if it is now a \*(UU path or local address.
If the new address turns out to be another domain address,
.B smail
complains.
This error occurs when an address partially resolves to the local host.
.PP
By default,
.B smail
does not alter an explicit \*(UU path of any mail message.
If the stated path is unuseable (i.e., the next host is unknown) then
.B smail
applies always routing and attempts to deliver the message to first (leftmost)
system named in the \*(UU path.
If this fails,
.B smail
then uses reroute routing and again attempts to deliver the message.
If this too fails,
.B smail
finally attempts to to find a path to a
.B smart-host
and passes the mail to it.
And if that finally fails,
.B smail
mails an error message to user who mailed the message, and abandons any
further attempt to mail the message.
.SH Headers
Protocol RFC822, which governs Internet mail, demands that messages contains
certain headers, including
.BR To: ,
.BR From: ,
and
.BR Date .
If these headers are absent in locally generated mail,
.B smail
inserts them.
.SH "Build the From: Line of a Message"
The header of a mail message includes a line that begins
.BR From: .
This line names the user who originated the message.
This line is extremely important, as it will read by users and programs
on the recipient's system to identify the sender, and possibly reply to the
message.
.PP
.B smail
collapses the
.B From_
and
.B >From_
lines within a mail message to generate a simple
``from'' argument, which it then uses to create its own
.B From:
line.
This processing sometimes is called
.I from-ming
a message.
The following gives the rules for from-ming:
.IP \(bu 0.3i
First, it concatenates all hosts named on
.B "remote from"
lines, separating them from each other by `!'s.
.IP \(bu
It appends onto that concatenated address,
the address from the last
.B From_
line.
.IP \(bu
If that address is in domain format (i.e., the form
\fIuser\^\fB@\fIdomain\^\fR),
.B smail
rewrites it in bang-path format
(i.e., the form \fIdomain\^\fB!\fIuser\^\fR).
If a host or domain names the local system,
.B smail
ignores it.
.IP \(bu
Finally,
.B smail
removes redundant information from the
.B From_
line.
.PP
.B smail
generates its own
.B From_
line.
For mail that is to be forwarded via \*(UU,
.B smail
generates a line of the form \fBremote-from \fIhost\fR;
.I host
is the \*(UU hostname (not the domain name), so that
.B From_
can indicate a valid \*(UU path, thus leaving the sender's domain address in
.BR From: .
.SH "Undeliverable Mail"
.B smail
returns to sender all mail that is undeliverable.
A message is declared to be undeliverable if the user is unknown, or if
the user resides on an unknown host.
.SH Logging
If you are having problems with mail delivery and wish to log all messages,
simply create the directory
.BR /usr/spool/uucp/.Log/mail .
.B smail
will automatically generate in that directory a log file named
.BR mail .
.B smail
will then log in that file every message that it handles.
.PP
If your system handles a large amount of mail, this log file
can grow very quickly.
You may wish to edit the script
.B uumvlog
to archive this file as well, before it consumes too much disk space.
.SH "Registered Domains and Subdomains"
.II NIC
You may wish to register your domain with the NIC.
This will give you an internationally recognized e-mail address.
For more information,
send e-mail to
.BR postmaster@nic.ddn.mil .
.PP
Once you have registered your domain, you can also set up subdomains for
other systems, so they can receive information from the Internet via your
system.
The rest of this section discusses how to describe subdomains to your
system, and related topics.
.PP
Let's say that you have registered your domain, and you have named it
.BR mydomain .
To route mail systems subordinate to
.BR mydomain ,
do the following:
.IP \fB1.\fR 0.3i
Insert the following entry into
.BR /usr/lib/mail/paths :
.DM
	.mydomain.com	%s	50
.DE
.IP
This tells
.B smail
that the local host (i.e., your machine) must resolve
that any address that ends in the suffix
.BR .mydomain.com ,
or it is an error.
.IP \fB2.\fR
For each site in
.BR mydomain ,
create two entries in
.BR /usr/lib/mail/paths .
For example, for the site
.BR foo.mydomain.com ,
create the entries :
.DM
	foo	foo!%s	200
	foo.mydomain.com	foo!%s	200
.DE
.IP
If the site
.B bar.mydomain.com
is fed by the route
.BR froboz!florp!bar,
insert these lines into
.BR paths :
.DM
	bar	froboz!florp!bar!%s	200
	bar.mydomain.com	froboz!florp!bar!%s	200
.DE
.PP
Note that you do not have to register subdomains with the NIC.
Once you register the top-level domain with the NIC, you
control the entire name space \(em you can subdomain to your heart's content.
.PP
The only restrictions on subdomaining may be with your Internet Nameserver.
Most nameservers for \*(UU domains publish a ``wildcard'' mail exchanger (MX)
record, that essentially says, ``send everything for *.mydomain.com to this
Internet gateway.''
However, some nameserver managers require you to
register every site in your domain, for which they provide a separate MX record.
The advantage of this scheme is that anybody on the Internet
sending mail to your domain gets an immediate error message if they are
sending to a non-existent site.
Check with the manager of your nameserver.
.PP
To route for an entire subdomain (e.g., \fB.subd.mydomain.com\fR),
you must choose a gateway for that domain (e.g.,
\fBgateway.subd.mydomain.com\fR), and then use a line like this:
.DM
	.subd.mydomain.com	gateway!%s	200
.DE
.PP
.B smail
automatically chooses the longest subdomain match it can find,
so this rule applies before the \fB.mydomain.com %s\fR rule.
.PP
Note that the gateway need not be in the subdomain itself.
You could have a line elsewhere in the
.B paths
file on
.B mydomain
that says:
.DM
	gateway.mydomain.com	gateway!%s	200
.DE
.PP
Your main gateway may also have information about machines in subdomains,
though this is not necessary.
For instance, if your main machine is directly connected
to a machine in a subdomain, you may want to put this information into
.BR paths ,
so the mail will not go through the gateway for that domain.
For example, the machine 
.B smith.subd.mydomain.com
might be directly connected to your master gateway,
.BR mydomain.com :
.DM
	smith	smith!%s	200
	smith.subd.mydomain.com	smith!%s	200
.DE
.PP
Without this rule, mail for
.B smith
would be queued up for forwarding through
.BR gateway.subd.mydomain.com .
.PP
Always remember to keep the
.B paths
file sort into alphabetical order.
.SH Files
.nf
\fB/bin/lmail\fR \(em Local mailer
\fB/bin/mail\fR \(em Mail user agent
\fB/usr/lib/mail/aliases\fR \(em Alias data base
\fB/usr/lib/mail/namelist\fR \(em Name list data base
\fB/usr/lib/mail/paths\fR \(em Path data base
\fB/usr/spool/uucp/.Log/mail/mail\fR \(em Log of mail
.fi
.SH "See Also"
.B
aliases,
\&.forward,
mail,
paths,
rmail
.R
.SH Notes
.B smail
and
.B rmail
are links to the same program.
