UNIX System Administration Handbook - Evi Nemeth [329]
A .forward file consists of a list of comma-separated addresses on a single line or several entries on separate lines. For example,
evi@ipn.caida.org
evi@xor.com
or
\mcbryan, "/home/mcbryan/archive", mcbryan@f1supi1.gmd.de
In the first example, mail for evi is not delivered on the local machine, but is instead forwarded to the machine ipn at CAIDA in San Diego and to xor.com. The second entry is from a user who does not trust mail systems and wants his mail replicated in three places: the regular mail spool on the local machine, a permanent archive of all incoming mail, and a temporary address in Germany where he is traveling at the moment. The backslash before his username says to deliver mail locally no matter what the aliases or forward files might say.
For temporary changes in mail routing, use of a .forward file is preferable to use of the global aliases file. The overhead (computer time and people time) required to change the system-wide aliases is quite high.
A user’s .forward file must be owned by the user and must not be group or world-writable. If sendmail thinks the directory path to the .forward file is safe (i.e., the permissions from the root all the way down are OK), it can be a link; otherwise, it cannot be a link. sendmail ignores forwarding files on which the permissions look suspicious; the permissions on the parent directory must also be safe (writable only by the user who owns the files).
Naturally, sendmail must be able to access a user’s home directory on the machine where mail is delivered to determine whether it contains a .forward file. Permanent changes of address should be put in the /etc/mail/aliases file because a user’s home directory and files will eventually be removed.
sendmail has a nifty feature, FEATURE('redirect'), that helps with the management of permanent email changes. If an alias points to user@newsite.REDIRECT, mail will be returned to the sender with a notification of the new address. The message is not forwarded to the new address, so the sender must update his address book and resend the message.
You can configure sendmail to support a central directory for .forward files, but users do not expect this configuration. The location of .forward files is controlled by the ForwardPath option, which usually points to that central directory and then to the user’s home directory. The generic.m4 domain file illustrated on page 594 contains an example of a central location for .forward files.
An entry in the global aliases file takes precedence over an entry in a .forward file. Since these files are maintained by different people, users must be careful not to inadvertently create mail loops. If a user on a network has a mail home (and therefore an entry in the global aliases file), that user cannot use a .forward file to reroute mail to another machine that shares the same aliases. For example, at the University of Colorado, where we use a site-wide aliases file, an entry such as
evi: evi@boulder
and a .forward file on the machine boulder containing
evi@anchor.cs
would create a loop. Mail addressed to evi would be forwarded to boulder, where the .forward file would cause it to be sent to anchor in the cs subdomain. The aliases file on anchor would cause it to be forwarded back to boulder, and so on. After 25 hops, the mail would be returned to the sender.
Notifying a user of a mail loop is challenging if your primary mode of communication is email. Mail to \user11
delivers the message on the local machine, regardless of what the system-wide aliases file or the user’s .forward file might say. If the local machine is where the user expects