Notes Mailx

Math 10 -- D. C. Smolarski, S.J.
Santa Clara University, Department of Mathematics and Computer Science

[Return to Math 10 Homepage]

Unix Mailx Commands

For use when dialing in, or telnetting into the server. It may also be used locally in lieu of other graphical interface programs.

To Start the mailer (after logging in): mailx

mailx will go to your mailfile in the "var/mail'' directory, an active mail file which contains new messages and messages that have not been saved in your mbox file or other file (which can be considered the archive files). Your mailfile in the "var/mail'' directory is identified by your username.

mailx will list the messages it contains (in groups of 20) with an initial code, a message number, the sender, the date and time sent, the size (lines and bytes), and the subject. A message can be read by merely indicating the number at the prompt (usually ?).

If there are new messages, the headers of those messages will be listed. If there are no new messages, the headers of the initial messages still in the "var/mail" file will appear.

If you only see the headers of the initial messages (e.g., the first 20 messages), enter the command h21 to have the headers starting with message 21 be listed on the screen.

Each message is preceded by a code: O (old), N (new), R (just read), U (unread).

In the chart of mailx commands below, [msglist] is used. [msglist] is optional and specifies messages by number, author, subject or type. If omitted, the default message is the current message. (The square brackets indicate the optional nature of [msglist] and are not actually included.)

To Send A Message

At the user prompt, one may merely invoke the command:
      (15)pozzo>mailx jdoe@mailer.scu.edu
after which mailx will prompt you for Subject, CC:, etc.

The message is ended via a period as the first character on a line. At this point, one will return to the user prompt.

One may also enter mailx and at its prompt, the ?, type m or mail and be prompted for the username, etc. One may also enter

       ? mail jdoe@mailer.scu.edu
after which you will be prompted for further information.

Once again, the message is ended via a period as the first character on a line. At this point, one will return to the mailer prompt.

At the user prompt, one may also send a file, e.g., filename1.ext using the input redirection symbol, <, as follows:

      (16)pozzo>mailx jdoe@mailer.scu.edu < filename1.ext

msglist Symbols

[msglist] may include the following commands/symbols in the next table (some of which may also be used at the mailx internal ? prompt):
n (integer) message number n
<enter> next message
. current message
^ first undeleted message
$ last message
* all messages
+ next undeleted message
- last undeleted message
n-m inclusive message range (from n to m)
user all messages from user
:c all messages of type c
where c is
d for deleted
n for new
o for old
r for read
u for unread
/string message with "string" in subject line

mailx commands

(to be entered at the ? prompt.)
(NOTE: parentheses indicate letters of a command which are optional and can be omitted.)
alias,group user ... declare alias for user names
alternates user declare alternate names for your login
cd,chdir [directory] chdir to directory or home if none given
!command shell escape
copy [msglist] file save messages to file without marking as saved
d(elete) [msglist] delete messages
discard,ignore header discard header field when printing message
dp,dt [msglist] delete messages and type next message
echo string print the string
e(dit) [msglist] edit messages
folder,file filename change mailboxes to filename
folders list files in directory of current folder
followup [msglist] reply to authors of messages and save copy
Followup [message] reply to all recipients of message and save copy
from [msglist] give header lines of messages
h(eader) [message] print page of active message headers
help,? print this help message
hold,preserve [msglist] hold messages in mailbox
inc incorporate new messages into current session
list list all commands (no explanations)
m(ail) user mail to specific user
Mail mail to specific user, saving copy
mbox [msglist] messages will go to mbox when quitting
next [message] goto and type next message
pipe,| [msglist] shell-cmd pipe the messages to the shell command
p(rint),t(ype) [msglist] print messages
Print,Type [msglist] print messages with all headers
q(uit) quit, preserving unread messages
r(eply),r(espond) [msglist] reply to authors (only) of the messages
R(eply),R(espond) [message] reply to the author and recipients of the msg
s(ave) [msglist] file save (appending) messages to file
Save [msglist] save messages to file named after author
set variable[=value] set variable to value
size [msglist] print size of messages
source file read commands from file
top [msglist] print top 5 lines of messages
touch [msglist] force the messages to be saved when quitting
undelete [msglist] restore deleted messages
undiscard,unignore header add header field back to list printed
unread,new [msglist] mark messages unread
version print version
v(isual) [msglist] edit list with $VISUAL editor
write [msglist] file write messages without headers
x(it),exit quit, preserving all messages
z [+/-] display next [last] page of 10 headers

Tilde commands

(to be entered at the beginning of a line when in "insert" mode when writing a mail message)
~ ~ Quote a single tilde
~a,~A Autograph (insert 'sign', 'Sign' variable)
~b users Add users to Bcc list
~c users Add users to Cc list
~d Read in dead.letter file
~e Edit the message buffer
~f messages Read in messages, do not right-shift
~h Prompt for Subject and To, Cc and Bcc lists
~i variable Insert variable into message (~a := ~i sign)
~m messages Read in messages, right-shifted by a tab
~p Print the message buffer
~q, ~Q Quit, save letter in $HOME/dead.letter
~r, ~< file Read a file into the message buffer
~r, ~< !command Read output from command into message
~R Mark message for return receipt
~s subject Set subject
~t users Add users to To list
~v Invoke display editor on message
~w file Write message onto file (no header)
~x Quit, do not save letter
~!command Run a shell command
~|, ~^ command Pipe the message through the command
~:, ~_ command Execute regular mailx command
~. end of input
~? print this help message

Using <ctrl>C twice will kill (abort) the current message being composed and append the text to the file named dead.letter.


This page is maintained by Dennis C. Smolarski, S.J. dsmolarski@math.scu.edu
© Copyright 1998 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 7 March 1998. Slightly modified 26 September 2001.