Linux mailx help and command examples(What is, Concept and Definition)
On Unix-like operating systems, the mailx command sends and receives mail.
This document covers the GNU/Linux version of mailx .
Description
mailx is an intelligent mail processing system, which has a command syntax reminiscent of ed with lines replaced by messages.It is based on Berkeley Mail 8.1, it is intended to provide the functionality of the mail command and offers extensions for MIME, IMAP, POP3, SMTP, and S/MIME . mailx provides enhanced features for interactive use, such as caching and disconnected operation for IMAP, message threading, punctuation and filtering.It can also be used as a mail batch language, both for sending and receiving mail.
Syntax
mailx [-BDdEFintv ~] [-s subject ] [-a attachment ] [-c cc-addr ] [-b bcc-addr ] [-r from-addr ] [-h jumps ] [-A account ] [-S variable [= value ]] a-addr ...mailx [-BDdeEHiInNRv ~] [-T name ] [-A account ] [-S variable [= value ]]-f [ name ] mailx [-BDdeEinNRv ~] [-A account ] [-S variable [= value ]] [-u user ]Options
-A name Run a account command (see below) for the name after the startup files have been read. -a file Attach the given file to the message.-B Make standard input and standard output with line buffer. -b list Sending blind copies to the list . list should be a list of names separated by commas. -c list Send carbon copies to the mailing list .
-D Start in offline mode; see the description of the disconnected variable option.
-d Enables debugging messages and disables actual message delivery.Unlike -v , this option is for development purposes only.
-e Check for mail in the system mailbox.If yes, return an exit status of zero, otherwise a non-zero value.
-E If an outgoing message does not contain any text in its first or only part of the message, do not send it, but discard it silently, effectively setting the skipemptybody variable at the start of the program.This is useful for sending messages.from scripts started by cron. -f [ file ] Read from user mailbox contents (or file , if specified) for processing; when mailx is closed it rewrites not deleted messages into this file.The string file is handled as described for the folder command below.
-F Save the message to send in a file named after the local part of the first recipient's address.
-H Print header summaries for all messages and exit. -h hops Invoke sendmail with the specified hop count.This option has no effect when SMTP is used to send mail.
-i Ignore tty interrupt signals.This is particularly useful when using mailx on noisy phone lines.
-I Show the fields ' Newsgroup: ' or ' Article-Id: ' in the header summary.Only applicable when used in combination with -f .
-n Inhibits reading /etc/mail.rc at startup.This option should be enabled for mailx scripts that are invoked on more than one machine, because the content of that file can differ between them.
-N Inhibits the initial display of message headers when reading mail or editing a mail folder. -q file Starts the message with the content of the specified file.It can only be in send mode. -r address Sets the From address.Overrides any de variable specified in environment variables or startup files.Tilde escapes are disabled.-r address options are passed to the agent Mail transfer unless SMTP is used.This option exists for compatibility only; it is recommended to establish the variable from directly instead.
-R If you open folders, it opens them read-only. -s subject Specify the subject on the command line (only the first argument after the -s flag is used as the subject; be careful to quote topics that contain spaces). -S variable [= value ] Set the internal variable option variable to the optional value value . -T name Write the header fields ' Message ID: ' and ' Article Id: ' for each message read in the file name.Include -I .Compressed files are handled as described for the folder command below.
-t The message to send is expected to contain a message header with ' To: ', ' Cc: ' or ' Bcc: ' fields that deliver to their recipients.Recipients specified on the command line are ignored. -u user Read the mailbox of the user user .
-v Detailed mode Delivery details are displayed in the user terminal.
-V Show version information and exit.
-~ Enable tilde escapes even if you are not in interactive mode.
Sending mail
To send a message to one or more people, mailx can be invoked with arguments that are the names of the people to whom the mail will be sent.Write your message, followed by a ' control-D ' at the beginning of a line, signaling the end of the message, and implicit approval to send it.
Read mail
In normal use, mailx receives no arguments and extracts the user's mail from the mail server, then prints a one-line header of each message found.The current message is initially the first message ( numbered 1 ) and can be printed using the print command which can be abbreviated ' p ').User can move between messages as much as he moves between lines in ed, with the commands ' + ' and '-' moving back and forth, and single numbers.
Deletion of mail
After browsing a message, the user can delete (' d ') the message, or reply ' r ') to it.Deletion makes the mailx program forget the message.This is not irreversible; the message can be undelete d (' u ') when giving its number, or the session mailx can be canceled giving the exit command (' x ').However, deleted messages will generally disappear, never to be seen again.
Specify messages
commands like print and delete can receive a list of message numbers as arguments to apply to many messages at once.Therefore, ' delete 1 2 'delete 1 and 2 messages, while' delete 1-5 'delete messages 1 to 5 .In ordered or threaded mode (see the order and thread commands), ' delete 1-5 'removes the messages between (and includes) the messages 1 to 5 in the ordered/threaded order, as shown in the summary of the header.The following special message names exist:
| : n | All new messages. |
| : o | All old messages (any that are not in read or new state). |
| : u | All unread messages. |
| : d | All deleted messages (for the undelete command). |
| : r | All messages read. |
| : f | All 'marked' messages. |
| : a | All messages answered (see variable markanswered ). |
| : t | All messages marked as draft. |
| : k | All 'dead' messages. |
| : j | All messages that have been classified as junk. |
| . | The current message. |
| ; | The message that was previously the current message. |
| , | The main message of the current message, that is, the message with the message ID provided in the field ' In response to: ' or the last entry in the references' : 'field of the current message. |
| - | The next previous unretrieved message or the next previous deleted message for the undelete command.In sorted/threaded mode, the next previous message in the sorted/threaded order. |
| + | The next message not deleted or the next message deleted for the undelete command.In ordered/threaded mode, the following message in the ordered/threaded order. |
| ^ | The first message not deleted or the first message deleted for the undelete command.In ordered/threaded mode, the first message of this type in the ordered/threaded order. |
| $ | The last message.In sorted/threaded mode, the last message in the sorted/threaded order. |
| & x | In thread mode, selects the directed message with x , where x is any other message specification and all messages in the thread that starts with it.Otherwise, it is identical to x .If x is omitted, the thread that begins with the current message is selected. |
| * | All messages. |
| ' | All messages that were included in the message list for the previous command. |
| / string | All messages containing string in the subject field (case ignored).See also variable search engines .If string is empty , the string from the above specification of that type is used again. |
| address | All messages from address address . |
| ( criterion ) | All messages that meet the given IMAP style search criteria.This addressing mode is available with all kinds of folders; For folders not located on IMAP servers, or for servers that cannot execute the SEARCH command, mailx will search locally.Strings must be enclosed in double quotation marks ' "' in fully if they contain white space or parentheses; in quotes, only the backslash ' \ ' is recognized as an escape character All string searches are not case sensitive.indicates that the 'over' representation of an address field is used, this means that the search string is compared against a list constructed as a source ("real name" "-rute" "local-part" "domain-part") for each address, and addresses without real names in the respective header field.Criteria can be nested using parentheses. |
| ( criteria1 criteria2 ... criteriaN ) | All messages that meet all the given criteria. |
| (or criterion1 criterion2 ) | All messages that satisfy criteria1 or criteria2 , or both.To connect more than two criteria using 'o', the (o) specifications must be nested using additional parentheses, as with ' (oa (or bc)) '; ' (oabc) ' means ((aob) and c) .For a simple 'u' operation of independent criteria at the lowest nesting level, it is possible to achieve similar effects using three separate criteria, as with ' (a) (b) (c) '. |
| (no criterion ) | All messages that do not meet the criterion . |
| (bcc string ) | All messages containing strings in the 'over' representation of the Bcc: field. |
| (cc string ) | All messages containing string in the 'over' representation of the Cc: field. |
| (de string ) | All messages containing string in the 'over' representation of the From: field. |
| (subject string ) | All messages containing string in the Subject: field. |
| (a string ) | All messages containing string in the 'over' representation of the To: . |
| (header name string ) | All messages containing string in the specified Name: field. |
| (body string ) | All messages that contain string in their body. |
| (text string ) | All messages that contain string in their header or body. |
| (larger size ) | All messages that are larger than size (in bytes). |
| (smaller size ) | All messages that are smaller than size (in bytes). |
| (formerly date ) | All messages that were received before date ; date must be in the form d// |
Comments
Post a Comment