You can use the mail program to create, send, reply, and forward messages to other users or to send ASCII files to other users. An ASCII file may, for example, be a document you have written using a preferred editor or a source file for a program.
The mail program provides a line-oriented editor for creating messages. This editor enables you to enter each line of the message, press the Enter key to get a new line, and enter more text. When you create mail with the mail editor, the date: and from : fields are automatically completed by the system. You have the option to complete the subject: and cc: fields. These fields are similar to the body of a standard business letter. Other editors can only be used by using the editor subcommands.
You can send messages and files to a user on your local system, on your network, or to a user on another connected network. The recipient does not need to be logged onto the system when you send the information. Mail is sent to a user's address. The address, containing the login name and system name, directs the delivery of the mail message.
For more information about creating and sending mail, see:
Mail is sent to a user's address. The address, containing the login name and system name, directs the delivery of the mail message. Generally, to send a message to another user, you must enter the mail command and the address as follows:
How you address mail depends on whether you are sending the mail:
However, the format of the Address parameter depends upon the location of the recipient. The concept is similar to how you might address a note to a fellow worker in an office. To send a note to Ryan, who works in a small department of six to eight people, you might simply write the name on an envelope and put it in the office mail system. However, if Ryan is in another department, you may have to provide more information on the envelope:
If Ryan is in another plant, you may need even more information to ensure that the message reaches him:
Ryan Payroll Gaithersburg
|mail ryan||To send mail electronically, use a similar addressing progression. To send mail to a user on your local system, the login name is the only part of the address required.|
|mail ryan@tybalt||To send mail to a user on your local network, enter the full system (node) address.|
|mail firstname.lastname@example.org||To send mail to a user on another connected network, enter the full system address and network address.|
|mail dept71||You can send mail to a specific group of people by using an alias or distribution list. To do so, you must create an alias or distribution list in your .mailrc file. If you need information on creating aliases, see "Creating an Alias or Distribution List".|
Note: More than one user can be addressed at the same time on the command line.
The mail program must be installed on your system.
To send a message to a user on your local system (to someone whose login name is listed in your /etc/passwd file), use the login name for the address. At your system command line prompt, you can use the mail command in the way shown in the following example:
|mail ryan||If Ryan is on your system and has the login name ryan . This command activates the mail program, enables you to create a message, and tries to send the message to a local login name of ryan . If the message is delivered successfully, you receive no notification. If Ryan is not on your system, the mail system immediately returns an error message and returns the unsent message to your system mailbox.|
To send a message through a local network to a user on another system, at the command line enter:
|mail LoginName@SystemName|| For example, if Ryan is on system zeus, use the following command to create and send a message to him:
This command activates the mail program, enables you to create a message, and tries to send the message to login name ryan on system zeus . If the message is delivered successfully, you receive the system prompt with no notification. If the mail address is incorrect, you will receive an error message.
Note: To send a message through a local network to a user on another system, you must know the login name and the name of the other system. For more information on this, see "Communications System Commands for End Users".
If your network is connected to other networks, you can send mail to users on the other networks. The address parameters differ depending on how your network and the other networks address each other and how they are connected.
Using a Central Database of Names and Addresses: at your system command line prompt, you can use the mail command in the way shown in the following example:
|mail LoginName@SystemName|| If the networks use a central database of names, you do not need any additional information to send mail to users on the connected networks. Use the same addressing format as for users on your local network.
This type of addressing works well when the nature of the network allows a central database of names to be maintained.
Using Domain Name Addressing: at your system command line prompt, you can use the mail command in the ways shown in the following examples:
|mail LoginName@SystemName.DomainName||For networks that span large, unrelated networks in widespread locations, a central database of names is not possible. The DomainName parameter defines the remote network, relative to your local network, within the defined structure for the larger group of interconnected networks.|
|mail email@example.com||In this example, user kelly is on the system merlin that is on a local network, named odin , that is connected to a second network whose domain is called valryanl .|
To send a message to a user on another system connected to your system by the Basic Networking Utilities (BNU) or another version of UNIX-to-UNIX Copy Program (UUCP), you must know:
The person responsible for connecting your system to other systems should be able to provide routing information to address the other system.
When Your Computer Has a BNU or UUCP Link: at your system command line prompt, you can use the mail command in the ways shown in the following examples:
|mail UUCPRoute!LoginName||If your local computer has a BNU or UUCP connection that can be used to reach the remote system, use the format in this example to address a message. The variable LoginName is the login name on the remote system for the message recipient. The variable UUCPRoute describes the physical route the message must follow along the UUCP network. If your system is connected to the remote system without any intermediate UUCP systems between, this variable is the name of the remote system.|
|mail arthur!lancelot!merlin!ken||If your message must travel through one or more intermediate UUCP systems before reaching the desired remote system, this variable is a list of each of the intermediate systems. The list starts with the nearest system and proceeds to the farthest system, separated by an ! (exclamation mark). You can follow this example, if the message must travel through systems arthur and lancelot (in that order) before reaching merlin .|
|mail merlin!ken||If your local system has a UUCP link to a system called merlin and there are no other UUCP systems between your system and merlin , you can send a message to ken on that system.|
When the BNU or UUCP Link Is on Another Computer: in a local or wide area network environment, one of the systems on the network may have a BNU or other type of UUCP connection to a remote system. You can use that UUCP connection to send a message to a user on that remote UUCP system. At your system command line prompt, you can use the mail command in the way shown in the following example:
|mail @arthur:merlin!ken||Sends mail to ken on UUCP system merlin from the Internet system arthur . The delimiter @ is for the internet addressing, the delimiter ! is for the UUCP addressing, and the delimiter : connects the two addresses. Notice that in this format you are not sending mail to a user at any of the intermediate systems, so no login name precedes the @ in the domain address.|
|Sends mail to kelly on UUCP system acct.dept through system odin from the Internet system arthur .|
|Sends mail to bill@dept3 over odin and dept1 UUCP links and then over the local network link between systems dept2 and dept3 . The /etc/sendmail.cf file must be configured accordingly to use this type of UUCP address notation. See your system administrator for information.|
If you often send mail to users on other networks, creating aliases that include the users' addresses can save you time. See "Creating an Alias or Distribution List".
The mail program provides a line-oriented editor for composing messages. This editor enables you to enter each line of the message, press the Enter key to get a new line, and enter more text. You cannot change a line once you have entered it. However, before pressing the Enter key, you can change information on that one line by using the Backspace and Delete keys to erase. You can also use mail editor subcommands to enter a full-screen editor and change the message.
The mail editor includes many control subcommands that enable you to perform other operations on a message. Each of these subcommands must be entered on a new line and must begin with the special escape character ~ (tilde). You can change this escape character to any other character by including the set escape option in your .mailrc file.
At your system command line prompt or your mailbox prompt, you can use the mail command in the ways shown in the following examples:
|mail User@Address||Issue this command from the command line prompt. The message is addressed to User@Address. The Address parameter depends upon the location of the recipient.|
|m User@Address||Issue this subcommand from the mailbox prompt. The message is addressed to User@Address. The Address parameter depends upon the location of the recipient.|
For more information, see "Sending Mail". The mail editor is also activated, if you use the (R)eply or (r)eply subcommands to reply to a message. For more information on how to reply to a message, see "Replying to Mail".
While in your mailbox, you can add information to an existing message by entering the (e)dit or (v)isual subcommand at the mailbox prompt. While in the mail editor, you cannot change information on a line once you have pressed the Enter key and gone on to the next line. You can change the content of your message before sending it by editing the message with another editor.
set EDITOR=PathNameThis defines the editor you activate with the ~e subcommand. The value of PathName must be the full path name to the editor program that you want to use. For example, the definition set EDITOR=/usr/bin/vi defines the vi editor for use with the ~e subcommand.
To add information to a message in your mailbox, enter the (e)dit subcommand or the (v)isual subcommand, followed by the message number. At the mailbox prompt, you can use either the e subcommand or the v subcommand in the ways shown in the following examples:
|e 13||To add a note to message 13 using the e editor (or whatever editor is defined in the .mailrc file).|
|v 15||To add a note to message 15 using the vi editor (or whatever editor is defined in the .mailrc file).|
If you do not specify a message number, the mail command activates the editor using the current message. When you leave the editor, you return to the mailbox prompt to continue processing the messages in the mailbox.
At the beginning of a line while in the mail editor, you can use either the ~e subcommand or the ~v subcommand in the ways shown in the following examples:
|~e||Activates the e editor or other editor that you define in the .mailrc file.|
|~v||Activates the vi editor or other editor that you define in the .mailrc file.|
This enables you to edit the text of the current message. When you leave the different editor, you return to the mail editor.
At the beginning of a line while in the mail editor, use the ~p subcommand in the way shown in the following example:
|~p||The editor displays the contents of the message including the header information for the message. The text scrolls up from the bottom of the display. The end of the message is followed by the mail editor's (Continue) prompt.|
If the message is larger than one screen and you have not set the page size for your terminal by using the stty command, the text scrolls off the top of the screen to the end. To look at the content of large messages, use the mail editor subcommands to view the message with another editor, see "Editing a Message".
To quit the mail editor without sending the message, use the ~q subcommand or the interrupt key sequence (usually the Alt-Pause or Ctrl-C key sequence). If you have entered any text, the mail command saves the message in the dead.letter file.
At the beginning of a line while in the mail editor, you can use the ~q subcommand in the way shown in the following example:
|~q||Quits the mail editor and the message is not sent. The message is saved in the dead.letter file in your home directory, unless you have not entered any text. The system prompt is displayed.|
|Ctrl-C||To quit the editor using an interrupt key sequence, press the break (Ctrl-C key sequence) or the interrupt (Alt-Pause key sequence). The following message is displayed:|
Note: When you exit the mail editor without sending the message, the previous content of the dead.letter file is replaced with the incomplete message. To retrieve the file, see "Adding a File and a Specific Message within a Message".
At the beginning of a line while in the mail editor, you can use the ~r subcommand in the way shown in the following example:
|~r schedule||Where schedule is the name of the file to include. In this example, the information in the file schedule is included at the current end of the message being written.|
At the beginning of a new line while in the mail editor, you can use either the ~f or ~m subcommands in the ways shown in the following examples:
|~f MessageList|| This appends the indicated message or messages to the end of the current message, but does not indent the appended message. Also, use this subcommand to append messages for reference whose margins are too wide to embed with the ~m subcommand.
Note: The parameter MessageList is a list of integers that refer to valid message numbers in the mailbox or folder being handled by mail. You can enter simple ranges of numbers also. For example:
|~m 2||This appends the indicated message to the end of the current message. The included message is indented one tab character from the normal left margin of the message. In this example, message 2 is appended to the current message.|
|~m 1 3||Appends message 1 and then message 3 to the end of the message being written, indented one tab from the left margin.|
At the beginning of a new line while in the mail editor, you can use the ~d subcommand in the way shown in the following example:
|~d||This retrieves and appends the contents of the dead.letter file to the end of the current message. At the (Continue) prompt, continue by adding to the message or by sending the message.|
The heading of a message contains routing information and a short statement of the subject. You must specify at least one recipient of the message. The rest of the heading information is not required. The information in the heading can include the following:
|To:||Contains the address or addresses for sending the message.|
|Subject:||Contains a short summary of the topic of the message.|
|Cc:||Contains the address or addresses for sending copies of the message. The contents of this field are part of the message sent to all who receive the message.|
|Bcc:||Contains the address or addresses for sending blind copies of the message. This field is not included as part of the message sent to all who receive the message.|
You can customize the mail program to automatically ask for the information in these fields by putting entries in your .mailrc file.
To add to or change information in more than one heading field, use the ~h subcommand. When you enter this subcommand on a new line while in the mail editor, the system displays each of the four heading fields, one at a time. You can:
Pressing the Enter key saves any changes to that field and displays the next field and its contents. When you press the Enter key for the last field (Bcc: ), you return to the editor.
~hThe system responds with the contents of the To: field and places the cursor at the end of that field:
To: mark@austin_If necessary, edit or add to the field. Then press the Enter key.
Subject: Fishng Trip_
Note: If you have changed this field, the cursor may not be at the end of the field.
To correct the misspelling in the subject, use the Cursor Right or Cursor Left key to position the cursor under the n in Fishng . Retype the rest of the subject to correct it to Fishing Trip . Press the Enter key.
Cc: mel@gtwn_To add another person to the copy list, ensure the cursor is at the end of the list, type a space, and type the new address:
Cc: mel@gtwn geo@austinThis expands the copy list to two persons. When you have completed the copy list, press the Enter key.
Use the ~s subcommand to set the Subject: field to a particular phrase or sentence. Using this subcommand replaces the previous contents (if any) of the Subject: field. At the beginning of a new line while in the mail editor, you can use the ~s subcommand in the way shown in the following example:
|~s Fishing Trip|| This changes the current Subject:
Note: You cannot append to the Subject: field with this subcommand. Use the ~h subcommand, as described in "To Edit the Heading Information".
At the beginning of a new line while in the mail editor, you can use the ~t, ~c , or ~b subcommands in the ways shown in the following examples:
|~t geo@austin mel@gtwn|
|This changes the current To: list:|
|~c geo@austin mel@gtwn|
|This changes the current Cc: list:|
|~b geo@austin mel@gtwn|
|This changes the current Bcc: list:|
Note: You cannot use the ~t, ~c, or ~b subcommands to change or delete the contents of the To: , Cc: , and Bcc: lists. Use the ~h subcommand, as described in "To Edit the Heading Information".
After you have entered the message and before sending it, you can reformat the message to improve its appearance by using the fmt shell program. At the beginning of a new line while in the mail editor, you can use the fmt command in the way shown in the following example:
|~| fmt||This uses the fmt command to change the appearance of the message by reflowing the information for each paragraph within defined margins (a blank line must separate each paragraph). The | (pipe) subcommand pipes the message to standard input of the command and replaces the message with the standard output from that command.|
Attention: Do not use the fmt command if the message contains embedded messages or preformatted information from external files. The fmt command reformats the heading information in embedded messages and may change the format of preformatted information. Instead, use the ~e or ~v subcommand to enter a full-screen editor and reformat the message.
To use the spell command to check your message for misspelled words, from the mail editor:
~! spell checkitIn this example, the ! (exclamation point) is the subcommand that starts a shell, runs a command, and returns to the mailbox. The spell command responds with a list of words that are not in its list of known words, followed by an ! (exclamation point) to indicate that you have returned to the mail program.
~! rm checkit
mail jan@brownThe system responds with:
Subject: Dept Meetingand press Enter. You can now enter the body of the text.
There will be a short department meeting this afternoon in my office. Please plan on attending.
The system displays the carbon copy field:
Cc: karen@hobo cliff@cross
Note: If you do not want to send copies, press Enter without typing.
Note: If you enter an address unknown to the system, or not defined in an alias or distribution list, the system responds with the login name followed by an error message:
[user ID]... User unknown
At the mailbox prompt, you can use the (r)eply/respond and (R)eply/respond subcommands in the ways shown in the following examples:
|r||The r subcommand creates a new message that is addressed to the sender of the selected message and copied to the people on the Cc: list (if any). The Subject: field of the new message refers to the selected message. The default value of the r subcommand is the current message. This default can be overridden by entering the message number after the r.|
|R||This starts a reply only to the sender of the message. The default value of the R subcommand is the current message.|
|R 4||This starts a reply only to the sender of the message. The default current message can be overridden by entering the message number after the R. This example starts a reply to message 4. The system responds with a message similar to the following:|
At the mailbox prompt, you can use the m subcommand in the way shown in the following example:
|m nita@beatrice||The Address parameter is any correct user address. This subcommand starts the mail editor and enables you to create a new message while in the mailbox. When you send the message, you will be returned to the mailbox prompt.|
While reading your mail, you might want to forward a specific note to another user. This task can be accomplished by using the ~f and ~m subcommands.
If you are going to be away from your normal network address, you can have your mail sent to another network address by creating the .forward file. The new address can be any valid mail address on your network or a network connected to yours. It can be the address of a coworker who will handle your messages while you are away. When you choose to forward your network mail, you do not receive a copy of any incoming mail in your mailbox. All mail is forwarded directly to the address or addresses that you have specified.
Use the following steps to forward specific mail messages.
m User@Hostwhere User refers to the login name of another user and Host is the name of the user's system. If the user is on your system, you can omit the @Host part of the address.
~m MessageNumberMessageNumber identifies the piece of mail to forward.
The mail command displays a message similar to the following:
Interpolating: 1 (continue)
Use the following steps to forward all your mail to another person.
cd pwdThe system responds with:
cat > .forward mark joe@saturn [END OF FILE][END OF FILE] represents the end of file character, which is the Ctrl-D key sequence on most terminals. This must be entered on a blank line.
The .forward file contains the addresses of the users you want your mail forwarded to. Your mail will be forwarded to mark on your local system, and to joe on system saturn .
Note: You will not receive any mail until you delete the .forward file.
This file must contain valid addresses. If it is a null file (zero length), your mail is not forwarded and is stored in your mailbox.
The mail program must be installed on your system.
vacation -IThis creates a .vacation.dir file and a .vacation.pag file where names of the people who send messages are kept.
carl, |"/usr/bin/vacation carl"The first carl entry is the user name to which mail is forwarded. The second carl entry is the user name of the sender of the vacation message. The sender of the mail message receives one vacation message from carl per week, regardless of how many messages are sent to carl from the sender. If you have your mail forwarded to someone else, the mail message from the sender is forwarded to the person defined in your .forward file.
Use the -f flag to change the frequency intervals at which the message is sent. For example, carl enters the following statement in the .forward file:
carl, |"/usr/bin/vacation -f10d carl"The sender of mail messages receives one vacation message from carl every ten days, regardless of how many messages are sent to carl from the sender.
From: firstname.lastname@example.org (Carl Jones) Subject: I am on vacation. I am on vacation until October 1. If you have something urgent, please contact Jim Terry <email@example.com>. --carlThe sender receives the message that is in the $HOME/.vacation.msg file, or if the file does not exist, the default message found in the /usr/share/lib/vacation.def file. If neither of these files exist, no automatic replies are sent to the sender of the mail message and no error message is generated.
rm .forward .vacation.dir .vacation.pag .vacation.msg
At the system command line prompt, you can use the xsend command in the way shown in the following example:
|xsend barbara||In this example, secret mail is being addressed to the login name barbara. When you press Enter, a single line editor is used to enter the text of the message. When you are finished entering your message, press the Ctrl-D key sequence or a . (period) to exit the mail editor and send the message. The xsend command encrypts the message before it is sent.|
Mail [5.2 UCB] [AIX 3.2] Type ? for help. "/usr/spool/mail/linda": 4 messages 4 new >N 1 robert Wed Apr 14 15:23 4/182 "secret mail from robert@Zeus"The message text directs you to read your secret mail on your host using the xget command.
xgetYou are prompted for the password that was previously set up using the enroll command. After entering your password, the xget command prompt is displayed followed by a listing of any secret mail. The mail program is used to display any secret mail. You must enter the (q)uit subcommand if you want to leave read and unread messages in the secret mailbox and prevent the xget command from deleting the messages.
Receiving and Handling Mail
Creating an Alias or Distribution List.
Customizing the Mail Program
Changing Text Editors Used for Entering Messages
Changing Text Editors Used for Entering Messages.
Summary of Secret mail Commands
Summary of the Mailbox Subcommands in the Mail Program.
The .mailrc File Format.
The e command, vi command.
The fmt command.
The .forward file.
The vacation command.
The host command, mail command, uname command.
The enroll command, xsend command, xget command.