Note the following about setting up mail aliases in /etc/aliases:
Mail aliases in /etc/aliases are public. This means that if you set up a mail alias called softball, anyone can send to softball@your-machinename and make use of the mail alias.
When the mail is sent, /etc/aliases mail aliases are not expanded. For example, if you sent mail to softball@machinename, that's how the mail will read when it is received. The recipients will know what the mail alias is, but not necessarily who else is on it.
The format of mail aliases created in /etc/aliases is somewhat different from those in .mailrc. Each /etc/aliases alias should use the following format:
The recipients (logins and machine names), separated by commas. Note that the mail alias does not have to be on a single line.
To modify your /etc/aliases file, you must first become root. If root is password protected, you'll need to know the root password.
Type the following to become the root user on the system:
$ su Password: # |
Notice that the command prompt changes when you become root.
The following example shows how the alias softball@texas is added to the default /etc/aliases file.
You can use any text editor to edit the /etc/aliases file. The example above shows the method for using the vi editor to edit the file. If you are not already familiar with vi, refer to Chapter 6, Using the vi Editorfor instructions.
Note that the pound signs (#) you see within the /etc/aliases file have been placed there to comment out the text and sample aliases. The pound signs prevent the system from processing this information as actual aliases.
Do not place pound signs in front of aliases you add to this file, unless you intentionally want to disable an alias.
To send mail to people on a /etc/aliases alias, address the mail using the name of the alias and your machine name. For example, if you sent the following:
$ mail softball@texas Subject: Practice Today Let's meet at the diamond behind Building 4 after work tonight. Goodness knows we can use the practice for Saturday's game! Be there as early as you can. |
the recipients would see the following:
To: softball@texas Subject: Practice Today Let's meet at the diamond behind Building 4 after work tonight. Goodness knows we can use the practice for Saturday's game! Be there as early as you can. |
Notice that the To: line is not expanded.
Whenever you send mail using a mail alias of this type, be sure to include the machine name of the machine on which it's located. If you set up a mail alias called riders on the machine freeway, then you should send your mail to riders@freeway.
Table 7-1 provides a summary comparison between mail aliases created in .mailrc and those created in /etc/aliases.
Table 7-1 Comparing Mail Aliases in .mailrc and /etc/aliases
|
.mailrc |
/etc/aliases |
---|---|---|
Must be root to modify? |
no |
yes |
Send message to: |
alias |
alias@machinename |
Recipients list seen by recipients? |
yes |
no |
Names separated by commas? |
no |
yes |
Names all on one line? |
yes |
no |
Others can use the mail alias? |
no |
yes |
For more detailed information on mail aliases, type man aliases or man addresses at the system prompt.