Name

mailx

Synopsis

mailx [options] [users]

Read mail or send mail to other users. mailx is based on the traditional mail command, extended to provide support for MIME, IMAP, POP3, SMTP, and S/MIME. The mailx command allows you to compose, send, receive, forward, and reply to mail. mailx has two main modes: compose mode, in which you create a message, and command mode, in which you manage your mail.

mailx is most commonly seen nowadays in scripts. Most Linux distributions include several utilities that are richer in features and easier to use: mailers built into browsers such as Mozilla and Firefox, graphical mail programs distributed with GNOME (Evolution) and KDE (Kmail), and the terminal-based, full-screen utilities pine and elm. The GNU Emacs editor can also send and receive mail.

To get you started, here are two of the most basic commands.

To enter interactive mail-reading mode, type:

mailx

To begin writing a message to user, type:

mailx user

Enter the text of the message, one line at a time, pressing Enter at the end of each line. To end the message, enter a single period (.) in the first column of a new line and press Enter.

You can also provide much of the information on the command line, as shown in the following example:

mailx james -s "System Log" </var/log/messages

This command sends a message to the user james, with a subject line of System Log, and the text of the message read from the system logfile, /var/log/messages.

mailx has many more options and commands than we can describe ...

Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.