Creating Aliases and Mail Redirects
How to set up aliases and mail redirection.
Probably the simplest way to redirect mail (either from users who don't exist, or from users who do exist) is with the /etc/aliases file. The format is pretty simple; just follow the examples, which are like so:
1 On the left-hand side is the address on the local machine which you'd like redirected. So in the first case, firstname.lastname@example.org is the address which will be redirected.
2 On the right-hand side is the address it should be redirected to. So in the first case, email@example.com will be redirected to firstname.lastname@example.org
3 In the second case we have a slightly more complicated version; whereby mail is being sent to an outside address; in this case, email@example.com is being redirected to firstname.lastname@example.org
Note that the /etc/aliases file is read before local delivery takes place; so if you want to redirect the mail of a user who does actually exist, you can just add an entry for their name, and then specify where you'd like mail redirected to.
Editing this file deserves a bit of caution.
The file itself is not read by sendmail; a database is created from the file, and *that* is then read by sendmail (this is done for speed reasons). It's no longer rebuilt automatically (for security reasons); so you *must* remember to rebuild the aliases database immediately upon exiting editing the file (otherwise the log will fill with errors, one for every mail sent).
This is done with the 'newaliases' command. To make sure you always remember to rebuild the database (and do it as absolutely quickly as possible upon exiting editing the aliases file); edit the aliases file like so:
# vim /etc/aliases;newaliases
This will cause the 'newaliases' command to be run immediately when the vim process exits.
There are a number of other ways to redirect mail and answer mail for nonexistent users; but this is probably the simplest way in most cases.
The instructions and screen shots contained within this website are specific to services offered by Real Time Enterprises only.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".