Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
7.  Using Mail Saving and Retrieving Messages Reading Messages in Files and Folders  Previous   Contents   Next 
   
 

Using vi With mailx

You can use the vi text editor to compose messages while you run mailx. vi enables you to correct mistakes and add and delete text before you send your messages. If you are not already familiar with using vi, refer to Chapter 6, Using the vi Editor for instructions.

In the mailx program, you can use the standard vi commands for inserting, deleting, and changing text.

To write a message with vi:

  1. Type the mailx command with an address at either the mailx prompt (&) or the command prompt ($).

  2. Type the subject at the Subject: line. Press Return.

  3. Start vi by typing the command ~v on a new line.

    The vi screen appears, representing an empty file in your /tmp directory.

  4. Use vi commands to type and edit the body of your message.

  5. When you are finished, quit vi with the command :wq or ZZ.

    After you quit vi, mailx displays the (continue): message. You can either add to the message (outside vi) or send the message by pressing Ctrl-D.

Mail Aliases

A mail alias is a selection of user names that are grouped under a single name.

Use mail aliases when you want to send messages to the same group of people over and over. For example, if you occassionally send mail to hank@fretful, george@lonesome, and sally@dakota, you could create a mail alias called amigos. Then, each time you sent mail to amigos, all three people would receive it.

Two locations where you can set up mail aliases are:

  • Your .mailrc file

  • The /etc/aliases file

Mail aliases that are set up in .mailrc behave differently from mail aliases set up in /etc/aliases. These differences are summarized in Table 7-1 at the end of this section.

Setting Up Mail Aliases in .mailrc

Note the following about setting up mail aliases in .mailrc:

  • Mail aliases in .mailrc are private. That is, only you can use them. For example, if you set up a mail alias called amigos in .mailrc and another user tries to send mail to amigos, he receives an unknown user error message.

  • When the mail is sent, .mailrc aliases are automatically expanded to show everyone on the mail alias. For example, if you send mail to amigos, your mail arrives as though you had typed everyone's names as recipients. The recipients do not know that you used a mail alias to send the mail.

.mailrc is located in your home directory. This file contains several settings that control the behavior of mailx and Mail Tool.

To add a mail alias to .mailrc, type:

$ vi ~/.mailrc    

Note - You can use any text editor to edit the .mailrc 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.


Each mail alias is contained on one line of the file. That is, the line can visually "wrap around" to another line, but it cannot contain carriage returns. Each mail alias should contain the following, separated by spaces:

  • The word "alias"

  • The name of the mail alias (must be one word)

  • The recipients (logins and machine names) in the mail alias, separated by spaces

The following example shows two mail aliases. The first alias (amigos) contains three people. The second alias (softball) contains eight. Notice in softball how the names are visually wrapped around on the screen. This is fine, as long as no carriage returns are used.

alias amigos hank@fretful george@lonesome sally@dakota
alias softball earl@woofer tex@twister elmer@farmhouse
jane@freeway hank@fretful jj@walker sally@dakota steve@hardway

To send mail to people on a .mailrc alias, address the mail to the mail alias name. Do not include your machine name. Suppose that you sent the following message:

$ mail amigos
Subject: Let's eat

Hey Compadres. How about
getting together for lunch on Friday?
Anyone interested?

The recipients would see the following (note the expanded To: line):

To: hank@fretful george@lonesome sally@dakota
Subject: Let's eat

Hey Compadres. How about getting together for lunch on Friday?
Anyone interested?

Setting Up Mail Aliases in /etc/aliases

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 name of the mail alias, followed by a colon (:)

  • 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)
$
 
 
 
  Previous   Contents   Next