mail, Mail, or mailx Command Purpose Sends and receives mail. Syntax To Read Incoming Mail { mail | Mail | mailx } [ -d ] [ -n ] [ -N ] [ -f [ PathName ] | [ -u UserID ] ] To Send Mail { mail | Mail | mailx } [ -d ] [ -i ] [ -n ] [ -N ] [ -s Subject ] [ -v ] Address ... Description The mail command starts the Mail program enabling you to: * Read incoming mail * Send mail * Customize the way the Mail system operates. In addition, you can use mailbox subcommands and mail editor subcommands with the Mail program. The mail command operates on two types of mailboxes, system and personal. Each user on a system is assigned a system mailbox. A user's system mailbox is a file located in the /var/spool/mail directory. The mailbox file is named for the user ID. For exam- ple, if your user ID is jeanne, then your system mailbox is /var/spool/mail/jeanne. The system mailbox contains mail that a user has received but has not read, deleted, or saved to a file. By default, when a user has read, deleted, or saved all the mail in their system mailbox, the mailbox is deleted. To prevent the mailbox from being deleted, use the set subcommand to set the keep option. Otherwise, you can prevent deletion of the mailbox by setting permissions on the /usr/mail directory to 775 (other does not have write permission). In addition to the system mailbox, each user is assigned a per- sonal mailbox. By default, the personal mailbox is the $HOME/mbox file. For example, if your home directory is /home/lance, the /home/lance/mbox file is your personal mailbox. When you view mail in your system mailbox, the Mail program puts all messages you have read but not deleted or saved into your personal mailbox. The messages remain in your personal mailbox until you move them to a folder or delete them. Folders provide a way to save messages in an organized fashion. You can create as many folders as you need. Name each folder with a name that pertains to the subject matter of the messages that it contains. You can put a message into a folder from your system mailbox, your personal mailbox, the dead.letter file, or from another folder. Examining the Contents of Your Mailbox The mail command uses several environment variables which can be specified in the /etc/profile file or the $HOME/.profile file. The command shell for the mail command calls the following vari- ables: MAIL Specifies the location of the system mailbox for system mes- sages to the user. When the user is notified that they have mail, the message contains the location of the system mailbox. The MAIL environment variable value is used in that message. The system default value if the MAIL environment variable is not specified is the /var/spool/mail directory. MAILBOX Specifies the location of the system mailbox for the mail command. The MAILBOX value is where the mail command searches for mail messages. The system default value if the MAILBOX en- vironment variable is not specified is the /var/spool/mail direc- tory. The Bourne shell (bsh command) for the mail command calls the following variables: MAILCHECK Specifies the interval at which the system checks the system mailbox for mail. MAILMSG Specifies the message sent to your console shell by the system when you have mail. The default message is similar to the following: YOU HAVE NEW MAIL To process your mail, enter mail at the system prompt. For each piece of mail in your system mailbox, the Mail program displays a one-line entry similar to the following: Mail [5.2 UCB] [Workstation 3.1] Type ? for help. "/usr/mail/lance": 2 messages 2 new >N 1 karen Thu Sep 17 14:36 13/359 "Dept Meeting" N 2 lance@zeus Thu Sep 17 15:06 10/350 "Delay" N 1 karen Thu Sep 17 14:50 13/359 "Meeting Cancel" & Each one-line entry displays the following fields: status Indicates the current class of a piece of mail. The status can be any of the following: M A message that will be stored in your personal mailbox. > The current message. N A new message. P A message to be preserved in your system mailbox. R Indicates that you have read the message. U An unread message. An unread message is a message that was listed in the mailbox last time you invoked the Mail program, but whose contents you did not examine. * A message that was saved or written to a file or folder. A message without a status indicates that the message has been read but has not been deleted or saved. number Identifies the piece of mail to the Mail program. sender Identifies the address of the person who sent the mail. date Specifies the date the message was received. size Defines the number of lines and characters contained in the letter (including the header). subject Identifies the subject of the message if it has one. Following the list of mail, the Mail program displays the mailbox prompt, & (ampersand), to indicate that it is waiting for input. Flags -d Causes the Mail program to display debugging information. Messages are not sent while in debug mode. -f [PathName] Displays a listing of the messages in your personal mailbox. When you quit the Mail program, messages that are not deleted are written back to this file. The default is $HOME/mbox. -i Causes tty interrupt signals to be ignored. -n Inhibits reading the /usr/share/lib/Mail.rc file. -N Suppresses the initial printing of headers. -s Subject Specifies a subject for a message to be created. -u UserID Short way of doing mail -f /var/spool/mail/UserID. Starts the Mail program for a specified user's mailbox. You must have access permission to the specified mailbox. -v Puts the Mail program into verbose mode. Details of delivery are displayed on the user's terminal. Examples 1. To start the Mail program and list the messages in your mail- box, enter the following at the command line prompt: mail A list of messages in your system mailbox is displayed. The list is followed by the mailbox prompt (&) to indicate waiting for in- put. When this prompt is displayed, enter any mailbox subcommand. To see a list of subcommands, enter: ? A list of Mail subcommands is displayed. 2. To look at the contents of your personal mailbox, enter the following at the command line prompt: mail -f A list of the messages in your personal mailbox, $HOME/mbox, is displayed. 3. To look at the contents of a specific mail folder, enter the following at the command line prompt: mail -f +dept A listing of the messages in the dept folder is displayed. 4. To send a message to a user on your local system, enter the following at the command line prompt: mail ron When you finish entering the message to user ron, press the Enter key and press either . (period) or Ctrl-D to exit the editor and send the message. To determine if a user is on your local sys- tem, check for the user's name is in your /etc/passwd file. If the message is delivered successfully, you receive no notifi- cation. If the message cannot be delivered, you receive an error message and the unsent message is placed in your system mailbox. 5. To send a file to another user on your local system, enter the following at the command line prompt: mail karen < letter1 In this example, the file letter1 is sent to user karen on your local system. After the message is sent, the command line prompt is displayed. 6. To send a message to a user on a remote system, enter the fol- lowing at the command line prompt: mail dale@zeus You now can create a message to dale. In this example, you are sending a message to user dale on remote system zeus. To send a message to a user on another system connected to your system through a network, you must know that person's login ID and the name of the other system. Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Files $HOME/.mailrc File containing mail subcommands to customize the Mail program for a specific user. $HOME/mbox Your personal mailbox. /usr/share/lib/Mail.rc File containing mail subcommands to change the Mail program for all users on the system. /var/spool/mail/* System mailboxes for all users. /usr/bin/mail The Mail program executable files. /usr/bin/Mail The Mail program executable files. /usr/bin/mailx The Mail program executable files. Related Information Mail Overview in AIX Version 3.2 System User's Guide: Communica- tions. Creating and Sending Mail in AIX Version 3.2 System User's Guide: Communications. Receiving and Handling Mail in AIX Version 3.2 System User's Guide: Communications. Mailbox Subcommands for the mail, Mail Command. Mail Editor Subcommands for the mail, Mail Command. The .mailrc file format. The bellmail command, fmt command, pg command, sendmail com- mand.