Next | Prev | Up | Top | Contents | Index

The .forward File

As an alternative to the alias database, users can put a file with the name .forward in their home directories. If the .forward file exists, in a user's home directory sendmail redirects mail for that user to the list of recipients in the file. The recipients are separated by commas or new lines. For example, if the home directory for user jane has a .forward file with the following contents, any mail arriving for jane is redirected to the specified accounts:

zippy@state.edu
bongo@widgets.com
The .forward file also allows the user to redirect mail to files or programs. A .forward file with the following contents redirects any incoming messages to jd@company.com, appends a copy of the message to the file /var/tmp/mail.log, and pipes a copy of the message to stdin of the /usr/bin/mymailer program:

jd@company.com
/var/tmp/mail.log 
| /usr/bin/mymailer
In general, file-type recipients must be writable by everyone. However, if sendmail is running as root and the file has setuid or setgid bits set, then the message will be written to the file.

Users can redirect mail to themselves in addition to sending it to other recipients. This feature is particularly useful if the users want to continue to receive mail in their own mailboxes while passing copies of each incoming message to some alternative destination. For example, say that the home directory for user john contains a .forward file with the following contents:

\john, |/usr/sbin/vacation

sendmail behaves as follows:


Next | Prev | Up | Top | Contents | Index