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 send mail to softball@machinename, that's how the mail reads when it is received. The recipients know what the mail alias is, but not necessarily who else is on it.
The format of mail aliases that are 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.
# vi /etc/aliases ## #Aliases can have any mix of upper and lower case on the left- #hand side, #but the right-hand side should be proper case (usually lower) # # >>>>>>>>>>The program “newaliases” will need to be run after # >> NOTE >>this file is updated for any changes to # >>>>>>>>>>show through to sendmail. # #@(#)aliases 1.10 89/01/20 SMI ## # Following alias is required by the mail protocol, RFC 822 # Set it to the address of a HUMAN who deals with this system's mail problems. Postmaster: root # Alias for mailer daemon; returned messages from our MAILER- DAEMON # should be routed to our local Postmaster. MAILER-DAEMON: postmaster # Aliases to handle mail to programs or files, eg news or vacation # decode: “|/usr/bin/uudecode” nobody: /dev/null # Sample aliases: # Alias for distribution list, members specified here: #staff:wnj,mosher,sam,ecc,mckusick,sklower,olson,rwh@ernie # Alias for distribution list, members specified elsewhere: #keyboards: :include:/usr/jfarrell/keyboards.list # Alias for a person, so they can receive mail by several names: #epa:eric ####################### # Local aliases below # ####################### softball@texas: earl@woofer tex@twister elmer@farmhouse jane@freeway hank@fretful jj@walker sally@dakota steve@hardway :wq (to quit viand save the /etc/aliasesfile ) # exit (to exit root) $ |
You can use any text editor to edit the /etc/aliases file. The previous example 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 Editor for 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 by using the name of the alias and your machine name. Suppose that 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 by 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 that are created in .mailrc and those that are 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.