mailx is a Unix utility program for sending and receiving mail, also known as a Mail User Agent program. Being a console application with a command syntax similar to ed, it is the POSIX standardized variant of the Berkeley Mail utility.
A simplified syntax with some commonly used options might include:
The end of message is indicated by hitting ctrl+d (and/or, dependent on the configuration settings, by writing a line consisting of a single '.'), causing the message to be passed asynchronously to the Mail transport agent. In order to send messages synchronously the mailx
internal, POSIX-standardized variable sendwait has to be set, usually in the system-wide initialization file (usually /etc/mail.rc); dependent on the used mailx
variant the (nonstandard) command-line option -S
can also be used, e.g., mailx -Ssendwait
.
By default, users compose messages in mailx
line by line, without the use of a text editor. The user may issue a command to mailx
by entering a line that begins with a tilde (~). The ~v command causes mailx
to invoke a text editor (defined by the VISUAL environment variable) on the message in progress, saved in a temporary file, and likewise for ~e (using the EDITOR environment variable).
Example usage: