15.5 Forwarding Email

You can forward incoming email messages with the Postfix local delivery agent or with Sendmail by configuring the /etc/aliases file. Entries in this file can map inbound addresses to local users, files, commands, and remote addresses.

The following example redirects email for postmaster to root, and forwards email sent to admin on the local system to several other users, including usr04, who is on a different system:

postmaster:   root
admin:        usr01, usr02, usr03, usr04@another-system.com 

To direct email to a file, specify an absolute path name instead of the destination address. To specify a command, precede it with a pipe character (|). The next example erases email sent to nemo by sending it to /dev/null, and runs a script named aggregator to process emails sent to fixme:

nemo:         /dev/null
fixme:        |/usr/local/bin/aggregator

After changing the file, run the command newaliases to rebuild the indexed database file.

For more information, see the aliases(5) manual page.