|Contents||Bulletin||Scripting in shell and Perl||Network troubleshooting||History||Humor|
|News||SMTP Mail||Recommended Links||Pipes in ~/.forward File||Dot forward file||Mail aliases|
|Scriptable and Command Line Mailers||Mutt||mailx||Grepmail||Perl Mail Processing Scripts||Decoding Mime Attachments|
|Scripting Language Based Spam and Mail filtering||UUCP||The Unix Haterís Handbook||Horror Stories||Humor||Etc|
The external mailx command is an electronic post office. You can send, receive, and store messages using the mailx command. It is based on the old mail command but provides a much better interface for handling messages. More modern and more capable version of mail command line client is Mutt which is cabale of handing attachment when sending emails.
You can use the tilde (~) commands to edit, review, and modify your message before sending it to the recipient. You can list, display, save, delete, and pipe messages while in command mode. In general terms mailx provides you with a memo/message handler. You can send to one or multiple users. You can reply to the original author or to the author and all other recipients of a message. It even allows you to store messages and replies in files based on user names.
Like many of the UNIX commands mailx has been changed and enhanced by most vendors. Therefore, there is no guarantee the information that follows pertains exactly to your system's mail program. The mailx information that follows is AT&T System V. The mail information is from various BSD based systems. Information common to all systems was used, hopefully providing a complete base of information for the BSD mail command.
Throughout the module we refer to the mailx command. The BSD mail command is assumed to be synonymous unless stated differently.
The old mail command is not documented in this book. It is slow, limited, and cumbersome to use. The BSD mail is usually located in /usr/ucb/mail. The mail program in /bin/mail is the old version of mail.
To Read Mail:
mailx [ -deFHIinNUV ] [ -f file ] [ -u user ] [ -T file ]
To Send Mail:
mailx [ -dFinUV ] [ -h num ] [ -r adr ] [ -s subject ] recipients
|To Read Mail:|
|/usr/ucb/mail [ -inv ][ -f file ][ -u user ]|
|To Send Mail:|
|/usr/ucb/mail [ -inv ][ -s subject ]recipients ]|
If you specify user_names, mailx attempts to send the message to the list of users. If you do not specify any user_names, mailx reads messages from your mailbox or specified file and enters command mode.
The following list describes the options and their arguments that may be used to control how mailx functions.
|-d||Turn on debugging mode. Debug statements are displayed.|
|-e||Checks for any mail in your mailbox. Nothing is displayed. A return code of 0 (true) is returned if mail does exist. A return code of 1 (false) is returned if no mail exists.|
|-F||Saves the mail message in a file named after the first user who received the message. This option overrides the internal record variable.|
|-f file||Reads mail from the file named file instead of your mailbox file (/usr/mail/ mylogin, BSD is /usr/spool/mail/mylogin). If you do not specify file, the file named mbox is used.|
|-H||Displays only the header summary information and exits from mailx.|
|-h num||Sets the number of "hops" a message has made to num. A hop is when a message is sent from one system to the next via a LAN (Local Area Network) or telephone line. This number is used by network mail delivery software to avoid infinite delivery loops. It is not intended for human use. Refer to the addsopt variable in the Internal Variables section.|
|-i||Causes mailx to ignore INTERRUPT signals. Refer to the ignore variable in the Internal Variables section.|
|-I||Displays the newgroup and article-id header lines in addition to the standard header lines that are displayed. Requires the -f option to be specified.|
|-n||Causes mailx not to initialize from the system default file, /usr/lib/mailx/ mailx.rc.|
|-N||Causes mailx not to display the header information during initial startup. By default, mailx displays the header line for each message contained in the mailbox file being read.|
|-r adr||Passes the address adr to network delivery software. The tilde commands are disabled. This option is used by mail delivery software. It is not intended for human use. Refer to the addsopt variable in the Internal Variable section.|
|-s subject||Sets the subject field of the message to subject. If subject contains blanks, you must use quotes. If this option is not used, you are prompted for a subject message each time you send a message to a user.|
|-T file||The message-ID and article-id header lines are saved in file after the message is read. Automatically sets the -I option.|
|-u user||Causes mailx to read messages from user's mailbox instead of your own. The specified user's mailbox must be readable by your userid. If it is read protected, mailx will complain and fail.|
|-U||Converts a uucp type address to internet standard type address. This option overrides the internal variable conv. Refer to the Internal Variables section.|
|-f [ filename ]||Same as mailx -f option|
|-i||Same as mailx -i option|
|-n||Same as mailx -n option|
|-s subject||Same as mailx -s option|
|-u user||Same as mailx -u option|
|-v||Sets verbose mode. Detailed delivery information is displayed.|
|Resembles mailx -d option.|
The -h, -r, and -U options can be used only if mailx uses a mail delivery program other than the /bin/mail program.
The following list describes the arguments that may be passed to the mailx command.
|recipients||A list of recipients to whom the mail message is sent. A recipient may be one of three types:|
|user_name||The name of a user on the local system or on a remote system. If the user is on a remote system, you must specify how the message is to be sent. The first is the uucp format of system!user. For example, sundal!mitek!rjf sends the mail to the system sundal, which forwards the mail to the system named mitek where the user rjf resides. The second is the internet format of user@system. The same address above is written as rjf@mitek.|
|shell_command||A UNIX shell command that reads the standard input. The recipient name must begin with a | (pipe). The command must be in quotes. For example,|
mailx rjf "|lp"
|sends the message to the user rjf and to the default printer.|
|alias_group||An alias_group allows you to define a group of users. You then specify the group name and the message is sent to each user in the group. For example, in your .mailrc file you might specify|
alias doc "aba barb ccb jag"
|so when you specify doc as a recipient all of the users in the "doc" alias_group are sent the message.|
Since mailx can be customized to each user's preferences, we discuss the default behavior of mailx in this section. You can customize mailx by using shell and internal variables.
When you want to send mail to other users, run mailx followed by a list of users. A header is added to the message you are sending. The header identifies you (the sender), the date of creation, and a subject line. The message is then sent to each user's mailbox in the /usr/mail (/usr/spool/mail on BSD) directory. The mailbox is a file named after the user's login or user name. For example, the user tlp has a mailbox named /usr/mail/tlp.
When you want to read your mail, run mailx without a list of users. mailx checks your mailbox for mail. If you have messages in your mailbox, mailx displays a header line for each message. You can then perform different commands to manipulate the message list and messages. If you read (or touch) a message, it is saved to the file mbox when you exit mailx. The mbox file contains messages you have received and did not delete or save in a different file. Your mailbox (/usr/mail/mylogin) contains all new messages that have not been read.
The mailx command is compatible with the older mail command and thus uses the same mailbox. The older mail program does not include a header for each message, nor the vast array of commands to handle messages.
To send mail you simply specify the users you want to send messages as arguments to mailx. For example,
mailx bill jill phil
sends the message you enter to the users, bill, jill, and phil. When you specify user names on the command line, mailx knows you want to send a message to recipients. After you press Return on the command line mailx prompts you for a subject line. You can press Return to have mailx ignore the subject line or you can enter a line of text. For example,
mailx barb Subject: About the database problem!
Only the first 40 characters of the subject line are displayed when the user displays the header information using the h command.
After you enter the Subject line, mailx enters a simple editor or input mode. You enter your message text line-by-line pressing Return at the end of each line. You can use the Backspace key to erase characters on the current line but you cannot return to previous lines. To end the message you press Ctrl-D at the beginning of a line.
You can use the tilde escape commands to perform special functions while in input mode. One of the tilde commands allows you to enter the editor of your choice to edit the message. So even though mailx does not provide a true editor, it does allow you to invoke one to edit your message. For example,
mailx barb Subject: About the database problem! ~v
causes mailx to enter the visual editor for you to edit your message.
The mailx header and tilde escape commands are discussed in the next two sections.
When you send a message using mailx a header is added to the message. The header contains information much like the header of a standard office memorandum. The header has a Date, From, To, and Subject field. The Date field is automatically set when you invoke mailx. It has the same format as the default format returned by the date command. The From field is your user_name and your name taken from the /etc/passwd file. The To field contains the names of all users you want to send the message. And the Subject field contains a brief line informing the recipients what the message is about.
This line and all other message header lines are displayed on the recipient's screen when mailx is first invoked. The header lines can be displayed at any time from the command mode by using the header command. There are environment variables and tilde escape commands you can use to control which parts of the header are displayed.
The mailx command also provides an additional field for Carbon Copy control. The Cc field can be used by setting the askcc variable or by using the ~c or ~h tilde escape command. This field is a list of users who are to receive the message. The list of users is displayed in the header so all users know who received the message. A similar field is the Bcc (blind carbon copy) field. It works the same as the Cc field except the list of users receiving a copy are not listed in the header. So other recipients are not informed of who received the message.
The header is composed of several different fields. These fields are:
|Status||The status of the message:|
|D - deleted message|
|N - new message|
|O - old message|
|R - read message|
|U - unread message|
|> - marks the current message|
|Date||The date the message was mailed|
|From||The user who sent the message|
|To||The user(s) to whom the message is sent|
|Subject||The subject to which the message relates|
|Cc||The users to whom carbon copies of the message is sent|
|Bcc||The users to whom blind carbon copies of the message is sent. Other users are not notified about who received a blind carbon copy.||
TILDE ESCAPE COMMANDS
The tilde escape commands allow you to edit and modify the message you are sending to the specified users. They can only be used while you are in insert mode. You can enter insert mode two ways. The first is by entering the mailx command from the shell, followed by user names. Another way to enter the input mode is from the command mode of mailx. The mail or reply commands place you in input mode.
When you are in input mode you can request special tilde escape commands by entering a tilde (~) followed by a command at the beginning of an input line. For example, ~v followed by Return, places you in the vi editor, thus allowing you to edit your message with vi.
You can change the escape character from tilde (~) to some other character by using the escape variable in mailx.
The following table describes each of the tilde escape commands.
|~!cmd||Causes mailx to invoke the cmd command. For example,
starts a subshell for you. When you want to return to entering your message, type Ctrl-D. Another example is
which lists your current directory.
|~.||Terminates input mode. The same as Ctrl-D.|
|~:mailx cmd||Executes a mailx command. You can only use this command if you|
|~_mailx cmd||entered the input mode from the command mode (you were reading mail).|
|~?||Displays a brief summary for the tilde escape commands.|
|~A||Inserts the value of the Sign variable into your message.
Usually Sign is set to a signature or sign-off type string.
For example, if you had
in your .mailrc file and you type ~A during input mode, mailx inserts "Sincerely" in you text.
|~a||Same as ~A except inserts the value of the sign variable.|
|~b name list||Add the names in name_list to the blind carbon copy (Bcc) list. The recipients of the message are not informed of who received blind copies of the message.|
|~c name list||Add the names in name_list to the carbon copy (Cc) list. The recipients of the message are informed who received carbon copies of the message.|
|~d||Reads the contents of the dead.letter file into your message. See the description of the DEAD variable. The dead.letter file is created by mailx when it is unable to send the message or it is interrupted. The incomplete message is stored in dead.letter.|
|~e||Invokes an editor so you can edit the message you are sending. The editor used depends on the value of the EDITOR variable.|
|~f msglist||Inserts the messages specified in msglist into your current message. This is considered forwarding the message on to another user. You can only use this command if you entered the input mode from the command mode (you were reading mail).|
|~h||Causes mailx to prompt you for the Subject, To, Cc, and Bcc fields. If a field already contains a value, you can edit it as if you just entered the value.|
|~i variable||Inserts the value of the specified variable into your message.
is equivalent to the ~A command. It inserts the value of the "Sign" variable.
|~m msglist||Inserts the messages specified in the msglist into your current message. The inserted message text is indented one tab stop. You can only use this command if you entered input mode from command mode (you were reading mail).|
|~p||Displays the message you are currently typing.|
|~q||Simulates a QUIT signal; causes mailx to be interrupted. The input session is aborted and mailx saves the message to the dead.letter file. If no text has been entered, mailx does not save to dead.letter. See the DEAD variable description.|
|~r filename||Reads the specified file into the message.|
|~< !cmd||Reads the standard output of the command cmd into the message.|
|~s string||Inserts string into the Subject field.|
|~t name list||Adds the specified names in name list to the To field.|
|~v||Invokes the editor defined by the VISUAL variable. The default is the vi editor.|
|~w filename||Writes the message you have entered so far to the file filename.|
|~x||Exits mailx like the ~q command except the message is not saved to the dead.letter file.|
|~|cmd||Sends (pipes) the message you have typed to the command cmd. If the shell_cmd exits with a return code of 0 (successful), the standard output of the cmd replaces the message.||
|The BSD mail program does not support the following tilde commands.|
To read the mail stored in your mailbox you simply run mailx without any arguments. For example,
If you do not have any mail to read, mailx returns a message stating that fact. If you have mail, a numbered list of messages is displayed on your screen and mailx enters command mode. For example,
$ mailx mailx version 2.2 9/9/88. Type ? for help. "/usr/mail/mylogin": 2 messages 2 unread >N 1 bill Tue Apr 12 08:31 5/134 "cabling problems" N 2 nancy Tue Apr 12 10:03 4/98 "lunch in the break area"
Each line in the list contains the status of the message (New, Old), the sender of the message, delivery time, the size in lines/bytes, and the subject. The current message is preceded by a > (greater than sign). Some of the messages will have subject fields, others may not.
After the list of messages is displayed you are prompted with a ? (question mark). You can type any of the command mode commands to manipulate the list of messages. Some examples are:
|?2||Read message number 2.|
|?q||Quit mailx. The read messages are saved to your mbox file. Messages that you have not read are left in your mailbox file (/usr/mail/mylogin, /usr/spool/mail/mylogin on BSD).|
|??||Enter a question mark for a brief summary of commands (the help screen).|
You are placed in command mode when you run mailx without specifying recipients on the command line. After the messages are displayed mailx prompts you for a command by displaying a ?. At the prompt you can type any of the following commands. The general format of these commands are:
[ command ] [ message_list ] [ argument(s) ]
If you do not specify a command, the print command is assumed. For example, to display the current message you just press Return. To display message number 2 you type 2 and press Return.
If you do not provide a message, the current message is assumed. If you do specify a message or list of messages, the specified command acts upon each message. For example,
deletes the current message. The command
deletes message number 2.
Some commands require arguments. You specify the arguments after the command and the message lists.
There are several identifiers you can use to specify a message list. Before we look at the commands, let's step through the possible identifiers you can use in a message list. A msg or msglist may consist of one or more of the following message identifiers.
|.||The current message. Preceded by a >|
|^||The first message. Deleted messages are ignored.|
|$||The last message. Deleted messages are ignored.|
|n||Message number n. The number n must be an integer.|
|n-m||Messages n through m. The numbers n and m must be integers.|
|user||All messages sent to you by the specified user.|
|/str||All messages that have the string str in the Subject field. The match is not case sensitive (str matches uppercase or lowercase equivalents).|
|:d||All deleted messages|
|:n||All new messages|
|:o||All old messages|
|:r||All read messages|
|:u||All unread messages|
The following table lists all of the commands you can use while in the command mode of mailx. Some commands only accept one message while others accept multiple messages. To distinguish between these commands we use msg to represent a single message and msglist to represent one or more messages. Any commands that use filenames for arguments may have a plus (+) placed before the filename to force the use of the folder variable.
|!cmd||Escapes to the shell and executes the UNIX command cmd.
After the command completes, control returns to mailx. For
lists the current directory in column format. Refer to the SHELL variable in the ENVIRONMENT VARIABLE section. Also refer to the bang variable.
|# comment||A comment. You may find this useful in the .mailrc file.|
|?||Displays a summary of internal mail commands.|
|=||Displays the current message number.|
|alias alias name(s)||Creates an alias string alias for a list of user names.
When you use alias as a recipient, all of the users listed
are substituted in place of the alias. For example,
alias mfg awk jji
substitutes awk and jji in place of mfg when you send mail to mfg. So the mail is actually sent to awk and jji.
|alternates [ name(s) ]||Establishes a list of alternate names you use to log in to various systems. When responding to messages using the reply command, these alternate user names are removed from the list of users to whom the message is sent. This prevents you from mailing a message to yourself that one of your alternate accounts previously forwarded. If you do not provide a name argument, the current list of alternate user names is displayed.|
|cd [ dir ]|
|chdir [ dir ]||Changes directory to the specified dir directory. If you do not specify a directory, $HOME is used.|
|co [ msglist ] [ file ]|
|copy [ msglist ] [ file ]||Copies the messages you specify in msglist to the given file. The messages are not marked as being saved. If you do not specify a msglist, the current message is copied. If you do not specify a file, the messages are copied to mbox unless you have defined the MBOX variable to a different filename.|
|C [ msglist ]|
|Copy [ msglist ]||Copies the messages to a file whose name is derived from the sender of each message. The messages are not marked as being saved. An example, ? Copy 1 saves message 1 to the file bill since the message was sent to you by the user bill.|
|d [ msglist ]|
|delete [ msglist ]||Deletes the messages specified in the msglist. The messages are removed from your system mailbox. If you have the autoprint variable set, the message following the last deleted message is displayed.|
|di [ header_field(s) ]|
|discard [ header_field(s) ]||Suppress the specified fields of each message header. For example,
causes the status field not to show up when you use the h command. Refer to the section of Header Fields for a list of header fields you may specify.
|dp [ msglist ]|
|dt [ msglist ]||Deletes the specified messages in msglist and displays the next message that follows the last message in msglist.|
|echo string||Echo the given string. Functions like the UNIX echo command. Used in the .mailrc file.|
|e [ msglist ]|
|edit [ msglist ]||Edit the messages you specified in the msglist. Each message is copied to a temporary file and edited. The name of the editor is the value of the EDITOR variable. If EDITOR is not set, the ed editor is used.|
|exit||Exits from mailx. The mailbox file is not changed. No messages are saved to the mbox file.|
|file [ file ]||Switches mailbox files from the current file to the new
mailbox file. For example,
causes mailx to quit the current file and read in the mbox file. If you do not specify a file, your system default file (/usr/mail/mylogin) is used. The file name may consist of one of the following special characters.
|%||Your current mailbox|
|%user||The mailbox belonging to user. You must have read access to the specified user's mailbox file.|
|#||The previous file you were viewing messages from.|
|&||Your mbox file.|
|folder file||Same as the file command.|
|folders||Displays the name of each file contained in your mail directory. A folder is synonymous to a file. Each folder contains messages to and from a user. You can specify the name of your mail directory using the folder variable.|
|followup [ msg ]||Sends your follow-up message to the author of the msg. A copy of the message you send is kept in a file named after the author of the original message. Ignores the value of the record variable.|
|Followup [ msglist ]||Sends your follow-up message to the author of each message in the msglist. Your response is to the first message in the message list. A copy of the message you send is stored in a file named after the author of the first message. The value of the record variable is ignored.|
|from [ msglist ]||Displays the header information for the specified messages.|
|group alias name(s)||Same as the alias command.|
|headers [ msglist ]||Displays the header lines for the specified messages. The number of header lines displayed at one time can be controlled by the screen variable or the z command.|
|help||Displays a brief summary of the more popular mailx commands.|
|hold [ msglist ]||Stores (holds) the specified messages in your mailbox (/usr/mail/mylogin).|
|en||See if, else, end that follow.|
|endif||The send or receive if else command. The mode is either
s (send) or r (receive). If the mode is set to
s, the commands up to the else or endif (if the else is not
provided) are executed. The commands after the else and before the
endif are executed if mailx is in the receive mode. If the
mode is r then the conditions are reversed. For example,
might be used in the .mailrc file to cause all messages you send to users to be piped to the lp command. If the messages are being read, then the cc and bcc fields are discarded from the header lines.
|ignore [ header_field(s) ]||Same as the discard command.|
|list||Displays a list of all command mode commands you can use while in mailx. No explanation is given for the commands. Helps jar your memory though.|
|mail name(s)||Allows you to mail a message to the specified user(s). mailx enters the send mode as if you had specified a list of names as arguments on the mailx command line.|
|mbox [ msglist ]||Causes the list of mail messages, msglist, to be copied to the mbox file when you exit mailx using the quit command. You can specify the name of the mbox file by setting the value of the MBOX variable to the desired name.|
|next [ msg ]||Search to the next message matching the specified msg. Refer to the message list section preceding these commands. You use this command to search forward for a message sent by a particular user or a message containing a particular string.|
|pipe [ msglist ] [ "cmd" ]||Pipes the messages you specify in msglist to the standard
input of the UNIX cmd command. For example,
pipe . "lp -dlaser"
sends the current message (.) to the UNIX lp command, with a destination printer of laser. If you do not specify a message, the current message is sent. If you do not provide a cmd command, the value of the cmd variable is used. If you have the page variable set, a form feed is inserted between each message. The pipe command flags the message as being read, which affects how other commands perform.
|preserve [ msglist ]||Same as the hold command.|
|print [ msglist ]||Displays each message to your screen. You can set the crt variable to control how many lines you want displayed per "page." The paging command defined by the PAGER variable is used to page through all of the messages. The default value for PAGER is the pg (more on BSD) command.|
|Print [ msglist ]||Same as the print command except the header fields are displayed even if the discard/ignore command has been used to suppress header fields.|
|quit||Quits mailx. Messages that you have read are saved to the mbox file. Messages that you have not read are returned to your mailbox (/usr/mail/mylogin). Messages marked for deletion are removed from your mailbox and are not saved to any file.|
|reply [ msg ]||Allows you to enter a reply to the author of the specified message. The subject line of the original message is used in your message. Your reply message is also sent to all the other recipients of the original message. If the record variable is set to a filename, then your reply message is saved in the file.|
|Reply [ msglist ]||Allows you to send a reply to the sender of each message specified in msglist. The subject line from the first message is used in your message as the subject line. A copy of your response message is saved in the file specified by the record variable. The Reply command is like the Followup command except Followup saves your response in a file named after the author of the original message, whereas Reply saves your response to a general response file or does not save the file at all.|
|respond [ msglist ]||Same as the reply command.|
|Respond [ msglist ]||Same as the Reply command.|
|Save [ msglist ]||Saves all of the messages in the msglist to a file named after the sender of the first message. Any network addressing is removed from the sender name.|
|save [ file ]|
|save [ msglist ] [ file ]||Saves the indicated messages to the file you specify. The first form saves the current message to the file. If you do not specify a file, the mbox file is used. Messages you save to a file are deleted from your mailbox unless you have the keepsave variable set.|
|set||Displays all internal variables and their values you have set. You can set these variables in the .mailrc file or in command mode using the set command. See the Environmental Variables section that follows for a full description of each variable.|
|set name||Set the Boolean variable to true. Use the unset command
to set the variable to false. For example,
sets the bang variable to true.
|set name=value||Set the variable to a specified numeric or string value. You can create variables of your own, then retrieve the value by using the ~i command.|
|shell||Invokes a subshell. By default the UNIX sh shell is invoked. You can specify the shell of your choice in the SHELL variable. To return to mailx after entering a subshell you can type exit and press Return or press Ctrl-D.|
|size [ msglist ]||Displays the size of each message in number of characters.|
|source file||Reads the file and executes each line as a mailx command. After the file has been processed, control returns to your current command mode session. An example would be if you made changes to your .mailrc file while in mailx and you want the changes to take effect without having to exit and re-enter mailx.|
|top [ msglist ]||Displays the first five lines of each message you specify. You can change the number of lines to any number you prefer by setting the toplines variable.|
|touch [ msglist ]||"Touches" each message you specify to be saved to mbox. Makes mailx consider the messages to have been read.|
|type [ msglist ]||Same as the print command.|
|Type [ msglist ]||Same as the Print command.|
|undelete [ msglist ]||Changes the status of deleted messages back to normal. You can only change the status of a message you have deleted in the current session of mailx. Once you exit mailx you cannot undelete a message you deleted in an earlier session. If you have the autoprint variable set, the last message in the msglist is displayed when you perform the undelete.|
|unset names(s)||Unsets or removes the value of the indicated mailx variables.|
|version||Displays the current version of the mailx you are using and the date it was released. Handy for those who just want to know and useful if you need to report problems to your vendor.|
|visual [ msglist ]||Invokes the editor specified by the visual variable. Each file in the msglist is edited. The default editor is vi.|
|write [ msglist ] file||Writes the specified messages in msglist to the file. The header information and trailing blank line are not copied to the file.|
|xit||Same as the exit command.|
|z[+]||Scrolls the list of header lines one screen forward. The screen variable may be set to control the number of lines displayed in a screen.|
|z-||Scrolls the list of header lines one screen backward. The screen variable may be set to control the number of lines displayed in a screen.|
|The BSD mail program does not support the following commands.|
|if s | r||touch|
|The BSD mail does, however, support the following commands that are not supported under System V mailx.|
|retain header_list||Opposite of the ignore command. It adds the given header names to the list of headers to retain. When mail displays the header fields only those in the retain list are displayed. With no arguments the list of retained header fields is displayed.|
|unread [ msglist ]||Mark each message in the given list as unread.|
You can set shell variables and internal mailx variables to control how mailx functions. Shell variables must be set before invoking mailx and cannot be changed from within mailx. Internal variables may be set while you are in command mode or in the .mailrc file.
The following variables are normal shell variables. You might want to set them in your .profile (.login or .cshrc-csh) file so they are always set correctly when you log in. For further information about shell variables refer to Module 99. You cannot change the value of these variables while inside mailx.
|HOME=directory||Defines your home directory. Your home directory is usually the same as your login directory (/u1/ts/mylogin).|
|MAIL=filename||The path where the initial mail is read. The default is /usr/mail/user on SV and /usr/spool/mail/user on BSD.|
|MAILRC=filename||Defines what file should be read by mailx during startup. If you do not define this variable, mailx looks for a file named $HOME/.mailrc.|
These variables are known only to the mailx command. You can set and unset them in the .mailrc file or at the command mode prompt. There are two basic types of variables, Boolean and assignment.
The first type is called Boolean. These variables have the value of true or false. If they are set they have a true value. If they are not set they have a false value. For example,
sets the askcc variable to true. Thus after you have entered your message to send, mailx prompts you for a Cc list.
If a variable is set to true, it is referred to as a normal name. If it is unset to false, its name becomes novarname. For example,
sets allnet to true. If you use the unset command to set the variable to false, the name changes to noallnet.
The second type of variables are called assignment variables. That is, you can assign values to the variable. For example,
set cmd="lp -dlaser"
sets the internal cmd variable to the string "lp -dlaser." So each time you use the pipe command, the messages are sent to the "lp -dlaser" command.
The following table describes the internal variables recognized by mailx. The Boolean variables are listed by name only. Assignment variables are listed with an equal sign (=) and a generic type value required.
|addsopt||True by default. It informs mailx to use the /bin/mail command to deliver messages. You can use the noaddsopt variable if you do not want to use the /bin/mail command. If you do not use /bin/mail, you cannot use the -h, -r, or -U options.|
|allnet||False by default (noallnet). Causes mailx to match all
messages with the same login name as identical. This ignores the
network address part of the message name. For example, the message
|are treated as equal names in a message list.|
|append||False by default (noappend). When true, causes mailx to append messages to the mbox file when you exit from read mode. The default is to insert the messages at the beginning of the mbox file.|
|askcc||False by default (noaskcc). When true, mailx prompts you for a list of users you want to send a Carbon copy (Cc) of the message.|
|asksub||True by default. When true, mailx prompts you for a Subject line when you send a message. If you do not type any text and just press Return, no subject is sent.|
|autoprint||False by default. When true, displays the last affected message automatically after you have used the delete or undelete command.|
|bang||False by default. When true, exclamation marks (!) used in shell escape commands are interpreted the same as in vi.|
|cmd=cmd||No default. Sets the cmd variable to the UNIX command cmd. A common cmd might be "lp -dlaser."|
|conv=conversion||Sets the method used to convert address formats. The only conversion supported at this time is internet, which converts uucp addresses to internet addresses. The uucp address format is system!user. The internet format is user@system. The internet format requires a mail delivery program to conform to the RFC822 standard for electronic mail addressing.|
|crt=number||If set to a number, causes messages containing more than number lines to be piped through the command defined by the PAGER variable. The PAGER variable is set to pg by default.|
|DEAD=file||Partial messages from when mailx was interrupted and undeliverable messages are stored in the specified file. The default file is dead.letter.|
|debug||False by default. When true, causes mailx to display verbose diagnostic messages for debugging. No messages are delivered if the debug variable is set.|
|dot||False by default. When true, causes a line beginning with a single dot (.) to terminate input when you are entering a message to be mailed.|
|EDITOR=cmd||Defines which editor is invoked when you use the tilde escape command ~e or the command mode command edit. The default value is ed.|
|escape=c||Sets the tilde escape character to character c. The default value of c is ~ (tilde). For example, if you set escape=%, then you would type %v to invoke the visual editor instead of ~v.|
|folder=directory||Defines which directory is used for saving mail files. To have
files saved to this directory you must precede them with a + (plus
sign). Suppose you have set folder=mail. Then you issue the following
|which saves the current message to the file named proj1 in the folder directory $HOME/mail ($HOME/mail/proj1). The directory name is assumed to be relative from your $HOME directory unless you begin it with a /. For example, folder=mail sets the directory to $HOME/mail. But folder=/tmp, sets the directory to /tmp.|
|If you want to reference files in your folder directory from
the UNIX command line, you must define a shell variable. For example,
|sets the shell variable folder to mail. This
must be done to perform commands such as
mailx -f +proj1
No default value exists for folder.
|header||True by default. When true, causes the first page of header lines to be displayed when you start mailx in read mode.|
|hold||False by default. Saves messages you have touched (read) in your mailbox (/usr/mail/mylogin) instead of your mbox file.|
|ignore||False by default. When true, causes mailx to ignore interrupt signals while in insert mode. This prevents mailx from saving the partial message to the dead.letter file and then aborting. It comes in handy when you are dialed in on a noisy line. A noisy phone line generates strange characters because of noise interference. It is not uncommon for these characters to be Breaks and Interrupts.|
|ignoreeof||False by default. When true, the end-of-file signal (Ctrl-D) is ignored during input mode. This is also handy for noisy dial-up lines. If you do set this variable to true, you must either use the ~. command or set the dot variable and use a single . to terminate input.|
|keep||False by default. When true, your mailbox (/usr/mail/mylogin) is kept even when empty. Normally, your mailbox is removed if it becomes empty.|
|keepsave||False by default. When set, a copy of a message is kept in your mailbox (/usr/mail/mylogin) even if you have saved the message to another file.|
|LISTER=cmd||Defines the UNIX command cmd to be used when you use the folders command to list files in the folder directory. The default cmd command is ls. You might want to try setting LISTER="ls -x".|
|MBOX=file||Specifies the file to save messages that have been touched (read) when you quit mailx. If you save files while in mailx, this variable is ignored. If you exit via the xit command, messages are not saved to the MBOX file. The default value of MBOX is $HOME/mbox.|
|metoo||False by default. If false, your name is removed from the list of recipients when you use the reply command. If true, your name is left in the list of recipients. Thus you receive a copy of the reply message.|
|onehop||False by default. When true, the reply command does not adjust return addresses based on the address of the first recipient. Instead, the reply message is sent to systems only one hop away. For example, let's say sunrise!tina sends mail to moovax!nancy and sunup!bill. If bill replies (using the reply command), his reply message is sent to sunrise!tina and sunrise!moovax!nancy. If onehop is set, then the replies are sent to sunrise!tina and moovax!nancy. You should only set onehop if you are on a local network where all systems can communicate with each other directly.|
|outfolder||False by default. When true, all messages saved with the Save, Copy, followup, and Followup commands are stored in the folder directory. The record variable must be set. If you specify an absolute path (a path beginning with a /), this variable is ignored.|
|page||False by default. When true, causes a form-feed character to be inserted between each message passed to a pipe command.|
|PAGER=cmd||Defines the UNIX command cmd to be used for paging through messages if the crt variable is set. The default cmd is pg.|
|prompt="str"||Defines the command mode prompt to be str. The default prompt is set to a ? (question mark blank).|
|quiet||False by default. When true, the beginning mailx message and version information is suppressed.|
|record=file||False by default. When set, causes all outgoing messages to be saved in file.|
|save||True by default. Causes messages that were interrupted to be saved in the dead.letter file. Refer to the DEAD variable.|
|screen=number||Defines the number of lines to be displayed by the header command.|
|sendmail=cmd||Defines the command used to send (deliver) mail. The default is mail. Most users don't worry with this variable.|
|sendwait||False by default. If true, mailx does not place a process in background when sending mail. Instead, your message is sent in the foreground. Control of your terminal is returned to you when the mail message has been delivered. May cause mailx to be extremely slow, depending on your system and the address resolution required.|
|SHELL=cmd||Defines the UNIX command to run when you use the ! or ~! commands. The default value is sh.|
|showto||False by default. When true, this variable causes the name of the recipient to be displayed in the header line instead of the sender. For example, if you send a message to Bill and a carbon copy to yourself, the message header will display your name because you're the sender. But if you set showto, then Bill's name would be displayed in the header line.|
|sign=str||Contains the string str that is inserted into your message when you use the ~a command. Contains no default value. Common use is to assign a signature or header to the variable.|
|Sign=str||Contains the string str that is inserted into your message when you use the ~A command. This variable contains no default value. Also used for signature or header type strings.|
|toplines=number||Defines the number of lines the top command uses. The default value is 5.|
|VISUAL=cmd||Defines the screen editor to use when you use the visual or ~v command. The default value is vi.|
|The BSD mail program does not support the following variables.|
|The BSD mail does, however, support the following variables that are not supported under System V mailx.|
|ask||Same as System V asksub variable|
|nosave||Same as System V save variable|
|verbose||Same as the -v option. The actual delivery of mail is performed in foreground and displayed on your screen, much like the sendwait variable in System V.|
You can use mailx to send mail to users on remote systems. These systems must be connected via a direct wire, a modem, or a LAN. If you are connected to remote systems, you can use the uucp address format or the Internet (Arpanet) format, depending on your site's setup. For information on how your system is connected to other systems, contact your system administrator. You can use mailx to send the system administrator mail by typing mailx root.
If you have a uucp connection to other systems, you can use the following address format:
where host is the name of the system and name is the name of the user you wish to send the message. This format is for a system directly linked to your system. To send to a system via "hops" (using other systems to get to the destination) you must specify each system in the path. For example,
would send the message to the mitek1 system, which would forward the message to the mitek3 system. The mitek3 system would forward the message to the mitek5 system, which would deliver the message to the user nancy.
If you are connected to the ARPANET or you have the network MAP for uucp, you can use the format:
to send the same message to the same user on mitek5. This is a much shorter and more convenient form of a remote address. But it does require a map of all systems you wish to send a message.
For further information on using remote mail at your site, contact your system administrator.
The mailx command provides a way to organize your mail. The feature is called folders. This feature allows you to save messages in a certain directory. Within this directory you can save messages to files based on the names of recipients, senders, or subjects.
There are a few preliminary steps you have to take before you can use the folder feature. The first step is to create a subdirectory in your HOME directory for storing mail items. For example,
cd mkdir mail
changes your working directory to $HOME and then creates a directory named mail. The next step is to edit your .profile file and add the following two lines.
folder=mail export folder
This sets the shell environment variable folder to mail. Since the path of the directory does not begin with a slash (/), the directory is assumed to be in your HOME directory. You must re-execute your .profile for this new variable to take effect or log out and log back in to the system. By setting this variable you can use the +filename feature on the shell command line when you invoke mailx. When you use a plus (+) before a filename mailx knows to place the message list in the directory defined by the folder variable. To re-execute your .profile type . ./.profile and press Return. Next, edit your .mailrc file. Add the following line.
This allows you to use a plus (+) inside mailx to have messages saved to files in the $HOME/mail directory.
Placing messages in folders
You can relate a file to a folder. Each folder in the folder directory contains a set of messages. You can use any of the mailx commands that have filenames as arguments to store messages to a folder file. For example,
saves the current message to a file with the name of the sender.
Once you have established different files for various types of messages you can use the folder command inside mailx to manipulate the messages stored within these different files. For example,
sets the current mailbox to MBOX. Thus all subsequent commands are based on the assumption that MBOX is your new mail file (folder). From the shell command line you can use the -f option to have a certain file be the mailbox. This allows you to use the mailx commands on the messages stored in the specified file. For example,
mailx -f MBOX
causes the same setup as the internal folder MBOX command.
The following list of files are used or updated by the mailx command.
|$HOME/.mailrc||Your personal customization file read by mailx at startup.|
|$HOME/mbox||Your secondary mailbox for story messages.|
|/usr/mail/||The post office directory, where each user's mailbox is stored (SV).|
|/usr/spool/mail||The post office directory (BSD).|
|/usr/lib/mailx/mailx.help*||The files containing the help messages (SV).|
|/usr/lib/mailx/mailx.rc||The default customization file read by mailx at startup. Used by all users on the system (SV).|
|/tmp/R[emqsx]*||Temporary files used for various mailx requirements.|
The mailx command can be invoked with the -e option to only return a return code. If you have mail in your mailbox, mailx returns a 0 (zero); otherwise, mailx returns a nonzero value.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit exclusivly for research and educational purposes. If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner.
ABUSE: IPs or network segments from which we detect a stream of probes might be blocked for no less then 90 days. Multiple types of probes increase this period.
Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda : SE quotes : Language Design and Programming Quotes : Random IT-related quotes : Somerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds : Larry Wall : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOS : Programming Languages History : PL/1 : Simula 67 : C : History of GCC development : Scripting Languages : Perl history : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history
The Peter Principle : Parkinson Law : 1984 : The Mythical Man-Month : How to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not Least
Copyright © 1996-2016 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License.
Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info|
The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: April 01, 2015