JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
man pages section 1: User Commands     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

Introduction

User Commands

acctcom(1)

adb(1)

addbib(1)

admin(1)

alias(1)

allocate(1)

amt(1)

appcert(1)

apptrace(1)

apropos(1)

ar(1)

arch(1)

as(1)

asa(1)

at(1)

atq(1)

atrm(1)

audioconvert(1)

audioctl(1)

audioplay(1)

audiorecord(1)

audiotest(1)

auths(1)

auto_ef(1)

awk(1)

banner(1)

basename(1)

basename(1B)

batch(1)

bc(1)

bdiff(1)

bfs(1)

bg(1)

biff(1B)

break(1)

builtin(1)

cal(1)

calendar(1)

case(1)

cat(1)

cd(1)

cdc(1)

cdrw(1)

chdir(1)

checkeq(1)

checknr(1)

chgrp(1)

chkey(1)

chmod(1)

chown(1)

chown(1B)

ckdate(1)

ckgid(1)

ckint(1)

ckitem(1)

ckkeywd(1)

ckpath(1)

ckrange(1)

ckstr(1)

cksum(1)

cktime(1)

ckuid(1)

ckyorn(1)

clear(1)

cmp(1)

col(1)

comb(1)

comm(1)

command(1)

compress(1)

continue(1)

cp(1)

cpio(1)

cpp(1)

cputrack(1)

crle(1)

crontab(1)

csh(1)

csplit(1)

ct(1C)

ctags(1)

ctrun(1)

ctstat(1)

ctwatch(1)

cu(1C)

cut(1)

date(1)

dc(1)

deallocate(1)

decrypt(1)

delta(1)

deroff(1)

df(1B)

dhcpinfo(1)

diff(1)

diff3(1)

diffmk(1)

digest(1)

digestp(1)

dircmp(1)

dirname(1)

dirs(1)

dis(1)

disown(1)

dispgid(1)

dispuid(1)

dos2unix(1)

dpost(1)

du(1)

du(1B)

dump(1)

dumpcs(1)

dumpkeys(1)

echo(1)

echo(1B)

ed(1)

edit(1)

egrep(1)

eject(1)

elfdump(1)

elfedit(1)

elffile(1)

elfsign(1)

elfwrap(1)

encrypt(1)

enhance(1)

env(1)

eqn(1)

errange(1)

errdate(1)

errgid(1)

errint(1)

erritem(1)

error(1)

errpath(1)

errstr(1)

errtime(1)

erruid(1)

erryorn(1)

eval(1)

ex(1)

exec(1)

exit(1)

expand(1)

export(1)

exportfs(1B)

expr(1)

expr(1B)

exstr(1)

factor(1)

false(1)

fastboot(1B)

fasthalt(1B)

fc(1)

fg(1)

fgrep(1)

file(1)

file(1B)

filebench(1)

filep(1)

filesync(1)

filofaxp(1)

find(1)

finger(1)

fmt(1)

fmtmsg(1)

fold(1)

for(1)

foreach(1)

franklinp(1)

from(1B)

ftp(1)

function(1)

gcore(1)

gencat(1)

geniconvtbl(1)

genmsg(1)

get(1)

getconf(1)

getfacl(1)

getlabel(1)

getopt(1)

getoptcvt(1)

getopts(1)

gettext(1)

gettxt(1)

getzonepath(1)

glob(1)

goto(1)

gprof(1)

grep(1)

groups(1)

groups(1B)

grpck(1B)

hash(1)

hashcheck(1)

hashmake(1)

hashstat(1)

head(1)

helpdate(1)

helpgid(1)

helpint(1)

helpitem(1)

helppath(1)

helprange(1)

helpstr(1)

helptime(1)

helpuid(1)

helpyorn(1)

hist(1)

history(1)

hostid(1)

hostname(1)

i386(1)

i486(1)

iconv(1)

if(1)

indxbib(1)

install(1B)

ipcrm(1)

ipcs(1)

isainfo(1)

isalist(1)

jobs(1)

join(1)

jsh(1)

kbd(1)

kdestroy(1)

keylogin(1)

keylogout(1)

kill(1)

kinit(1)

klist(1)

kmdb(1)

kmfcfg(1)

kpasswd(1)

krb5-config(1)

ksh(1)

ksh88(1)

ksh93(1)

ktutil(1)

kvno(1)

lari(1)

last(1)

lastcomm(1)

ld(1)

ldapadd(1)

ldapdelete(1)

ldaplist(1)

ldapmodify(1)

ldapmodrdn(1)

ldapsearch(1)

ldd(1)

ld.so.1(1)

let(1)

lex(1)

lgrpinfo(1)

limit(1)

line(1)

list_devices(1)

listusers(1)

llc2_autoconfig(1)

llc2_config(1)

llc2_stats(1)

ln(1)

ln(1B)

loadkeys(1)

locale(1)

localedef(1)

logger(1)

logger(1B)

login(1)

logname(1)

logout(1)

look(1)

lookbib(1)

lorder(1)

ls(1)

ls(1B)

m4(1)

mac(1)

mach(1)

machid(1)

madv.so.1(1)

mail(1)

Mail(1B)

mail(1B)

mailcompat(1)

mailp(1)

mailq(1)

mailstats(1)

mailx(1)

make(1S)

makekey(1)

man(1)

mconnect(1)

mcs(1)

mdb(1)

mesg(1)

mkdir(1)

mkmsgs(1)

mkstr(1B)

mktemp(1)

moe(1)

more(1)

mp(1)

mpss.so.1(1)

msgcc(1)

msgcpp(1)

msgcvt(1)

msgfmt(1)

msggen(1)

msgget(1)

mt(1)

mv(1)

nawk(1)

nc(1)

ncab2clf(1)

ncakmod(1)

neqn(1)

netcat(1)

newform(1)

newgrp(1)

newsp(1)

newtask(1)

nice(1)

nl(1)

nm(1)

nohup(1)

notify(1)

nroff(1)

od(1)

on(1)

onintr(1)

optisa(1)

pack(1)

packagemanager(1)

page(1)

pagesize(1)

pargs(1)

passwd(1)

paste(1)

patch(1)

pathchk(1)

pax(1)

pcat(1)

pcred(1)

perl(1)

pfbash(1)

pfcsh(1)

pfexec(1)

pfiles(1)

pfksh(1)

pflags(1)

pfsh(1)

pftcsh(1)

pfzsh(1)

pg(1)

pgrep(1)

pkcs11_inspect(1)

pkg(1)

pkgdepend(1)

pkgdiff(1)

pkgfmt(1)

pkginfo(1)

pkglint(1)

pkgmerge(1)

pkgmk(1)

pkgmogrify(1)

pkgparam(1)

pkgproto(1)

pkgrecv(1)

pkgrepo(1)

pkgsend(1)

pkgsign(1)

pkgtrans(1)

pkill(1)

pklogin_finder(1)

pktool(1)

plabel(1)

pldd(1)

plgrp(1)

plimit(1)

pmadvise(1)

pmap(1)

pm-updatemanager(1)

popd(1)

ppgsz(1)

ppriv(1)

pr(1)

praliases(1)

prctl(1)

preap(1)

print(1)

printenv(1B)

printf(1)

priocntl(1)

proc(1)

prof(1)

profiles(1)

projects(1)

prs(1)

prt(1)

prun(1)

ps(1)

ps(1B)

psig(1)

pstack(1)

pstop(1)

ptime(1)

ptree(1)

pushd(1)

pvs(1)

pwait(1)

pwd(1)

pwdx(1)

radadrgen(1)

ranlib(1)

rcapstat(1)

rcp(1)

read(1)

readonly(1)

red(1)

refer(1)

regcmp(1)

rehash(1)

remote_shell(1)

remsh(1)

renice(1)

repeat(1)

reset(1B)

return(1)

rksh(1)

rksh88(1)

rlogin(1)

rm(1)

rmail(1)

rmdel(1)

rmdir(1)

rmformat(1)

rmmount(1)

rmumount(1)

roffbib(1)

roles(1)

rpcgen(1)

rpm2cpio(1)

rsh(1)

runat(1)

rup(1)

rup(1C)

ruptime(1)

rusage(1B)

rusers(1)

rwho(1)

sact(1)

sar(1)

sccs(1)

sccs-admin(1)

sccs-cdc(1)

sccs-comb(1)

sccs-delta(1)

sccsdiff(1)

sccs-get(1)

sccs-help(1)

sccshelp(1)

sccs-prs(1)

sccs-prt(1)

sccs-rmdel(1)

sccs-sact(1)

sccs-sccsdiff(1)

sccs-unget(1)

sccs-val(1)

scp(1)

script(1)

sdiff(1)

sed(1)

sed(1B)

select(1)

set(1)

setenv(1)

setfacl(1)

setlabel(1)

setpgrp(1)

settime(1)

sftp(1)

sh(1)

shcomp(1)

shell_builtins(1)

shift(1)

shutdown(1B)

size(1)

sleep(1)

soelim(1)

sort(1)

sortbib(1)

sotruss(1)

source(1)

sparc(1)

spell(1)

spellin(1)

split(1)

srchtxt(1)

ssh(1)

ssh-add(1)

ssh-agent(1)

ssh-http-proxy-connect(1)

ssh-keygen(1)

ssh-keyscan(1)

ssh-socks5-proxy-connect(1)

stop(1)

strchg(1)

strconf(1)

strings(1)

strip(1)

stty(1)

stty(1B)

sum(1)

sum(1B)

sun(1)

suspend(1)

svcprop(1)

svcs(1)

switch(1)

symorder(1)

sys-suspend(1)

sysV-make(1)

t300(1)

t300s(1)

t4014(1)

t450(1)

tabs(1)

tail(1)

talk(1)

tar(1)

tbl(1)

tcopy(1)

tee(1)

tek(1)

telnet(1)

test(1)

test(1B)

tftp(1)

time(1)

timemanp(1)

times(1)

timesysp(1)

timex(1)

tip(1)

touch(1)

touch(1B)

tplot(1)

tput(1)

tr(1)

tr(1B)

trap(1)

troff(1)

true(1)

truss(1)

tset(1B)

tsort(1)

tty(1)

type(1)

typeset(1)

ul(1)

ulimit(1)

umask(1)

unalias(1)

uname(1)

uncompress(1)

unexpand(1)

unget(1)

unhash(1)

unifdef(1)

uniq(1)

units(1)

unix2dos(1)

unlimit(1)

unpack(1)

unset(1)

unsetenv(1)

until(1)

updatehome(1)

uptime(1)

userattr(1)

users(1B)

uucp(1C)

uudecode(1C)

uuencode(1C)

uuglist(1C)

uulog(1C)

uuname(1C)

uupick(1C)

uustat(1C)

uuto(1C)

uux(1C)

vacation(1)

val(1)

valdate(1)

valgid(1)

valint(1)

valpath(1)

valrange(1)

valstr(1)

valtime(1)

valuid(1)

valyorn(1)

vc(1)

vedit(1)

ver(1)

vgrind(1)

vi(1)

view(1)

vipw(1B)

volcheck(1)

volrmmount(1)

w(1)

wait(1)

wc(1)

what(1)

whatis(1)

whence(1)

whereis(1B)

which(1)

while(1)

who(1)

whoami(1B)

whocalls(1)

whois(1)

write(1)

xargs(1)

xgettext(1)

xstr(1)

yacc(1)

yes(1)

ypcat(1)

ypmatch(1)

yppasswd(1)

ypwhich(1)

zcat(1)

zlogin(1)

zonename(1)

zonestat(1)

mailx

- interactive message processing system

Synopsis

mailx [-BdeHiInNURvV~] [-f [file | +folder]] [-T file] 
     [-u user]
mailx [-BdFintUv~] [-b bcc] [-c cc] [-h number] 
     [-r address] [-s subject] recipient...
/usr/ucb/mail ...
/usr/ucb/Mail ...

Description

The mail utilities listed above provide a comfortable, flexible environment for sending and receiving mail messages electronically.

When reading mail, the mail utilities provide commands to facilitate saving, deleting, and responding to messages. When sending mail, the mail utilities allow editing, reviewing and other modification of the message as it is entered.

Incoming mail is stored in a standard file for each user, called the mailbox for that user. When the mail utilities are called to read messages, the mailbox is the default place to find them. As messages are read, they are marked to be moved to a secondary file for storage, unless specific action is taken, so that the messages need not be seen again.This secondary file is called the mbox and is normally located in the user's HOME directory (see MBOX in ENVIRONMENT VARIABLES for a description of this file). Messages can be saved in other secondary files named by the user. Messages remain in a secondary file until forcibly removed.

The user can access a secondary file by using the -f option. Messages in the secondary file can then be read or otherwise processed using the same Commands as in the primary mailbox. This gives rise within these pages to the notion of a current mailbox.

Options

On the command line options start with a dash (-). Any other arguments are taken to be destinations (recipients). If no recipients are specified, mailx attempts to read messages from the mailbox.

-B

Do not buffer standard input or standard output.

-b bcc

Set the blind carbon copy list to bcc. bcc should be enclosed in quotes if it contains more than one name.

-c cc

Set the carbon copy list to cc. cc should be enclosed in quotes if it contains more than one name.

-d

Turn on debugging output. (Neither particularly interesting nor recommended.)

-e

Test for the presence of mail. mailx prints nothing and exits with a successful return code if there is mail to read.

-F

Record the message in a file named after the first recipient. Overrides the record variable, if set (see Internal Variables).

-f [file]

Read messages from file instead of mailbox. If no file is specified, the mbox is used.

-f [+folder]

Use the file folder in the folder directory (same as the folder command). The name of this directory is listed in the folder variable.

-H

Print header summary only.

-h number

The number of network “hops” made so far. This is provided for network software to avoid infinite delivery loops. This option and its argument are passed to the delivery program.

-I

Include the newsgroup and article-id header lines when printing mail messages. This option requires the -f option to be specified.

-i

Ignore interrupts. See also ignore in Internal Variables.

-N

Do not print initial header summary.

-n

Do not initialize from the system default mailx.rc or Mail.rc file. See USAGE.

-r address

Use address as the return address when invoking the delivery program. All tilde commands are disabled. This option and its argument is passed to the delivery program.

-s subject

Set the Subject header field to subject. subject should be enclosed in quotes if it contains embedded white space.

-T file

Message-id and article-id header lines are recorded in file after the message is read. This option also sets the -I option.

-t

Scan the input for To:, Cc:, and Bcc: fields. Any recipients on the command line will be ignored.

-U

Convert UUCP-style addresses to internet standards. Overrides the conv environment variable.

-u user

Read user's mailbox. This is only effective if user's mailbox is not read protected.

-V

Print the mailx version number and exit.

-v

Pass the -v flag to sendmail(1M).

-~

Interpret tilde escapes in the input even if not reading from a tty.

Operands

The following operands are supported:

recipient

Addressee of message.

Usage

Starting Mail

At startup time, mailx executes the system startup file /etc/mail/mailx.rc. If invoked as mail or Mail, the system startup file /etc/mail/Mail.rc is used instead.

The system startup file sets up initial display options and alias lists and assigns values to some internal variables. These variables are flags and valued parameters which are set and cleared using the set and unset commands. See Internal Variables.

With the following exceptions, regular commands are legal inside startup files: !, Copy, edit, followup, Followup, hold, mail, preserve, reply, Reply, shell, and visual. An error in the startup file causes the remaining lines in the file to be ignored.

After executing the system startup file, the mail utilities execute the optional personal startup file $HOME/.mailrc, wherein the user can override the values of the internal variables as set by the system startup file.

If the -n option is specified, however, the mail utilities do not execute the system startup file.

Many system administrators include the commands

set appenddeadletter
unset replyall
unset pipeignore

in the system startup files (to be compatible with past Solaris behavior), but this does not meet standards requirements for mailx. To get standard behavior for mailx, users should use the -n option or include the following commands in a personal startup file:

unset appenddeadletter
set replyall
set pipeignore

When reading mail, the mail utilities are in command mode. A header summary of the first several messages is displayed, followed by a prompt indicating the mail utilities can accept regular commands (see Commands below). When sending mail, the mail utilities are in input mode. If no subject is specified on the command line, and the asksub variable is set, a prompt for the subject is printed.

As the message is typed, the mail utilities read the message and store it in a temporary file. Commands may be entered by beginning a line with the tilde (~) escape character followed by a single command letter and optional arguments. See Tilde Escapes for a summary of these commands.

Reading Mail

Each message is assigned a sequential number, and there is at any time the notion of a current message, marked by a right angle bracket (>) in the header summary. Many commands take an optional list of messages (message-list) to operate on. In most cases, the current message is set to the highest-numbered message in the list after the command is finished executing.

The default for message-list is the current message. A message-list is a list of message identifiers separated by spaces, which may include:

n

Message number n.

.

The current message.

^

The first undeleted message.

$

The last message.

*

All messages.

+

The next undeleted message.

-

The previous undeleted message.

n-m

An inclusive range of message numbers.

user

All messages from user.

/string

All messages with string in the Subject line (case ignored).

:c

All messages of type c, where c is one of:

d

deleted messages

n

new messages

o

old messages

r

read messages

u

unread messages

Notice that the context of the command determines whether this type of message specification makes sense.

Other arguments are usually arbitrary strings whose usage depends on the command involved. Filenames, where expected, are expanded using the normal shell conventions (see sh(1)). Special characters are recognized by certain commands and are documented with the commands below.

Sending Mail

Recipients listed on the command line may be of three types: login names, shell commands, or alias groups. Login names may be any network address, including mixed network addressing. If mail is found to be undeliverable, an attempt is made to return it to the sender's mailbox. If the recipient name begins with a pipe symbol ( | ), the rest of the name is taken to be a shell command to pipe the message through. This provides an automatic interface with any program that reads the standard input. Groups are set by the alias command (see Commands below) or in a system startup file (for example, $HOME/.mailrc). Aliases are lists of recipients of any type.

Forwarding Mail

To forward a specific message, include it in a message to the desired recipients with the ~f or ~m tilde escapes. See Tilde Escapes below. To forward mail automatically, add a comma-separated list of addresses for additional recipients to the .forward file in your home directory. This is different from the format of the alias command, which takes a space-separated list instead. Note: Forwarding addresses must be valid, or the messages will “bounce.” You cannot, for instance, reroute your mail to a new host by forwarding it to your new address if it is not yet listed in the NIS aliases domain.

Commands

Regular commands are of the form

[ command ] [ message-list ] [ arguments ]

In input mode, commands are recognized by the escape character, tilde(~), and lines not treated as commands are taken as input for the message. If no command is specified in command mode, next is assumed. The following is a complete list of mailx commands:

!shell-command

Escape to the shell. See SHELL in ENVIRONMENT VARIABLES.

# comment

NULL command (comment). Useful in mailrc files.

=

Print the current message number.

?

Prints a summary of commands.

alias alias name . . .
group alias name . . .

Declare an alias for the given names. The names are substituted when alias is used as a recipient. Useful in the mailrc file. With no arguments, the command displays the list of defined aliases.

alternates name . . .

Declare a list of alternate names for your login. When responding to a message, these names are removed from the list of recipients for the response. With no arguments, print the current list of alternate names. See also allnet in Internal Variables.

cd [directory]
chdir [directory]

Change directory. If directory is not specified, $HOME is used.

copy [file]
copy [message-list] file

Copy messages to the file without marking the messages as saved. Otherwise equivalent to the save command.

Copy [message-list]

Save the specified messages in a file whose name is derived from the author of the message to be saved, without marking the messages as saved. Otherwise equivalent to the Save command.

delete [message-list]

Delete messages from the mailbox. If autoprint is set, the next message after the last one deleted is printed (see Internal Variables).

discard [header-field. . . ]
ignore [header-field. . . ]

Suppress printing of the specified header fields when displaying messages on the screen. Examples of header fields to ignore are Status and Received. The fields are included when the message is saved, unless the alwaysignore variable is set. The More, Page, Print, and Type commands override this command. If no header is specified, the current list of header fields being ignored is printed. See also the undiscard and unignore commands.

dp [message-list]
dt [message-list]

Delete the specified messages from the mailbox and print the next message after the last one deleted. Roughly equivalent to a delete command followed by a print command.

echo string . . .

Echo the given strings (like echo(1)).

edit [message-list]

Edit the given messages. Each message is placed in a temporary file and the program named by the EDITOR variable is invoked to edit it (see ENVIRONMENT VARIABLES). Default editor is ed(1).

exit
xit

Exit from mailx, without changing the mailbox. No messages are saved in the mbox (see also quit).

field [message-list] header-file

Display the value of the header field in the specified message.

file [file]
folder [file]

Quit from the current file of messages and read in the specified file. Several special characters are recognized when used as file names:

%

the current mailbox.

%user

the mailbox for user.

#

the previous mail file.

&

the current mbox.

+file

The named file in the folder directory (listed in the folder variable).

With no arguments, print the name of the current mail file, and the number of messages and characters it contains.

folders

Print the names of the files in the directory set by the folder variable (see Internal Variables).

Followup [message]

Respond to a message, recording the response in a file whose name is derived from the author of the message. Overrides the record variable, if set. If the replyall variable is set, the actions of Followup and followup are reversed. See also the followup, Save, and Copy commands and outfolder in Internal Variables, and the Starting Mail section in USAGE above.

followup [message-list]

Respond to the first message in the message-list, sending the message to the author of each message in the message-list. The subject line is taken from the first message and the response is recorded in a file whose name is derived from the author of the first message. If the replyall variable is set, the actions of followup and Followup are reversed. See also the Followup, Save, and Copy commands and outfolder in Internal Variables, and the Starting Mail section in USAGE above.

from [message-list]

Print the header summary for the specified messages. If no messages are specified, print the header summary for the current message.

group alias name . . .
alias alias name . . .

Declare an alias for the given names. The names are substituted when alias is used as a recipient. Useful in the mailrc file.

headers [message]

Print the page of headers which includes the message specified. The screen variable sets the number of headers per page (see Internal Variables). See also the z command.

help

Print a summary of commands.

hold [message-list]
preserve [message-list]

Hold the specified messages in the mailbox.

if s | r | t
mail-commands
else
mail-commands
endif

Conditional execution, where s executes following mail-commands, up to an else or endif, if the program is in send mode, r causes the mail-commands to be executed only in receive mode, and t causes the mail-commands to be executed only if mailx is being run from a terminal. Useful in the mailrc file.

inc

Incorporate messages that arrive while you are reading the system mailbox. The new messages are added to the message list in the current mail session. This command does not commit changes made during the session, and prior messages are not renumbered.

ignore [header-field . . . ]
discard [header-field . . . ]

Suppress printing of the specified header fields when displaying messages on the screen. Examples of header fields to ignore are Status and Cc. All fields are included when the message is saved. The More, Page, Print and Type commands override this command. If no header is specified, the current list of header fields being ignored is printed. See also the undiscard and unignore commands.

list

Print all commands available. No explanation is given.

load

[message] file The specified message is replaced by the message in the named file. file should contain a single mail message including mail headers (as saved by the save command).

mail recipient. . .

Mail a message to the specified recipients.

Mail recipient

Mail a message to the specified recipients, and record it in a file whose name is derived from the author of the message. Overrides the record variable, if set. See also the Save and Copy commands and outfolder in Internal Variables.

mbox [message-list]

Arrange for the given messages to end up in the standard mbox save file when mailx terminates normally. See MBOX in ENVIRONMENT VARIABLES for a description of this file. See also the exit and quit commands.

more [message-list]
page [message-list]

Print the specified messages. If crt is set, the messages longer than the number of lines specified by the crt variable are paged through the command specified by the PAGER variable. The default command is pg(1) or if the bsdcompat variable is set, the default is more(1). See ENVIRONMENT VARIABLES. Same as the print and type commands.

More [message-list]
Page [message-list]

Print the specified messages on the screen, including all header fields. Overrides suppression of fields by the ignore command. Same as the Print and Type commands.

new [message-list]
New [message-list]
unread [message-list]
Unread

[message-list] Take a message list and mark each message as not having been read.

next [message]

Go to the next message matching message. If message is not supplied, this command finds the next message that was not deleted or saved. A message-list may be specified, but in this case the first valid message in the list is the only one used. This is useful for jumping to the next message from a specific user, since the name would be taken as a command in the absence of a real command. See the discussion of message-list above for a description of possible message specifications.

pipe [message-list] [shell-command]
| [message-list] [shell-command]

Pipe the message through the given shell-command. The message is treated as if it were read. If no arguments are given, the current message is piped through the command specified by the value of the cmd variable. If the page variable is set, a form feed character is inserted after each message (see Internal Variables).

preserve [message-list]
hold [message-list]

Preserve the specified messages in the mailbox.

print [message-list]
type [message-list]

Print the specified messages. If crt is set, the messages longer than the number of lines specified by the crt variable are paged through the command specified by the PAGER variable. The default command is pg(1) or if the bsdcompat variable is set, the default is more(1). See ENVIRONMENT VARIABLES. Same as the more and page commands.

Print [message-list]
Type [message-list]

Print the specified messages on the screen, including all header fields. Overrides suppression of fields by the ignore command. Same as the More and Page commands.

put [file]
put [message-list] file

Save the specified message in the given file. Use the same conventions as the print command for which header fields are ignored.

Put [file]
Put [message-list] file

Save the specified message in the given file. Overrides suppression of fields by the ignore command.

quit

Exit from mailx, storing messages that were read in mbox and unread messages in the mailbox. Messages that have been explicitly saved in a file are deleted unless the keepsave variable is set.

reply [message-list]
respond [message-list]
replysender [message-list]

Send a response to the author of each message in the message-list. The subject line is taken from the first message. If record is set to a file, a copy of the reply is added to that file. If the replyall variable is set, the actions of Reply/Respond and reply/respond are reversed. The replysender command is not affected by the replyall variable, but sends each reply only to the sender of each message. See the Starting Mail section in USAGE above.

Reply [message]
Respond [message]
replyall [message]

Reply to the specified message, including all other recipients of that message. If the variable record is set to a file, a copy of the reply added to that file. If the replyall variable is set, the actions of Reply/Respond and reply/respond are reversed. The replyall command is not affected by the replyall variable, but always sends the reply to all recipients of the message. See the Starting Mail section in USAGE above.

retain

Add the list of header fields named to the retained list. Only the header fields in the retain list are shown on your terminal when you print a message. All other header fields are suppressed. The set of retained fields specified by the retain command overrides any list of ignored fields specified by the ignore command. The Type and Print commands can be used to print a message in its entirety. If retain is executed with no arguments, it lists the current set of retained fields.

Save [message-list]

Save the specified messages in a file whose name is derived from the author of the first message. The name of the file is taken to be the author's name with all network addressing stripped off. See also the Copy, followup, and Followup commands and outfolder in Internal Variables.

save [file]
save [message-list] file

Save the specified messages in the given file. The file is created if it does not exist. The file defaults to mbox. The message is deleted from the mailbox when mailx terminates unless keepsave is set (see also Internal Variables and the exit and quit commands).

set
set variable
set variable=string
set variable=number

Define a variable. To assign a value to variable, separate the variable name from the value by an `=' (there must be no space before or after the `='). A variable may be given a null, string, or numeric value. To embed SPACE characters within a value, enclose it in quotes.

With no arguments, set displays all defined variables and any values they might have. See Internal Variables for a description of all predefined mail variables.

shell

Invoke an interactive shell. See also SHELL in ENVIRONMENT VARIABLES.

size [message-list]

Print the size in characters of the specified messages.

source file

Read commands from the given file and return to command mode.

top [message-list]

Print the top few lines of the specified messages. If the toplines variable is set, it is taken as the number of lines to print (see Internal Variables). The default is 5.

touch [message-list]

Touch the specified messages. If any message in message-list is not specifically saved in a file, it is placed in the mbox, or the file specified in the MBOX environment variable, upon normal termination. See exit and quit.

Type [message-list]
Print [message-list]

Print the specified messages on the screen, including all header fields. Overrides suppression of fields by the ignore command.

type [message-list]
print [message-list]

Print the specified messages. If crt is set, the messages longer than the number of lines specified by the crt variable are paged through the command specified by the PAGER variable. The default command is pg(1). See ENVIRONMENT VARIABLES.

unalias [alias] . . .
ungroup [alias] . . .

Remove the definitions of the specified aliases.

undelete [message-list]

Restore the specified deleted messages. Will only restore messages deleted in the current mail session. If autoprint is set, the last message of those restored is printed (see Internal Variables).

undiscard [header-field . . .]
unignore [header-field . . .]

Remove the specified header fields from the list being ignored. If no header fields are specified, all header fields are removed from the list being ignored.

unretain [header-field . . .]

Remove the specified header fields from the list being retained. If no header fields are specified, all header fields are removed from the list being retained.

unread [message-list]
Unread [message-list] Same as the new command.

unset variable . . .

Erase the specified variables. If the variable was imported from the environment (that is, an environment variable or exported shell variable), it cannot be unset from within mailx.

version

Print the current version and release date of the mailx utility.

visual [message-list]

Edit the given messages with a screen editor. Each messages is placed in a temporary file and the program named by the VISUAL variable is invoked to edit it (see ENVIRONMENT VARIABLES). Notice that the default visual editor is vi.

write [message-list] file

Write the given messages on the specified file, minus the header and trailing blank line. Otherwise equivalent to the save command.

xit
exit

Exit from mailx, without changing the mailbox. No messages are saved in the mbox (see also quit).

z[+ | -]

Scroll the header display forward or backward one screen-full. The number of headers displayed is set by the screen variable (see Internal Variables).

Tilde Escapes

The following tilde escape commands can be used when composing mail to send. These may be entered only from input mode, by beginning a line with the tilde escape character (~). See escape in Internal Variables for changing this special character. The escape character can be entered as text by typing it twice.

~ !shell-command

Escape to the shell. If present, run shell-command.

~.

Simulate end of file (terminate message input).

~ :mail-command
~_ mail-command

Perform the command-level request. Valid only when sending a message while reading mail.

~?

Print a summary of tilde escapes.

~A

Insert the autograph string Sign into the message (see Internal Variables).

~a

Insert the autograph string sign into the message (see Internal Variables).

~b name . . .

Add the names to the blind carbon copy (Bcc) list. This is like the carbon copy (Cc) list, except that the names in the Bcc list are not shown in the header of the mail message.

~c name . . .

Add the names to the carbon copy (Cc) list.

~d

Read in the dead-letter file. See DEAD in ENVIRONMENT VARIABLES for a description of this file.

~e

Invoke the editor on the partial message. See also EDITOR in ENVIRONMENT VARIABLES.

~f [message-list]

Forward the specified message, or the current message being read. Valid only when sending a message while reading mail. The messages are inserted into the message without alteration (as opposed to the ~m escape).

~F [message-list]

Forward the specified message, or the current message being read, including all header fields. Overrides the suppression of fields by the ignore command.

~h

Prompt for Subject line and To, Cc, and Bcc lists. If the field is displayed with an initial value, it may be edited as if you had just typed it.

~i variable

Insert the value of the named variable into the text of the message. For example, ~A is equivalent to `~i Sign.' Environment variables set and exported in the shell are also accessible by ~i.

~m [message-list]

Insert the listed messages, or the current message being read into the letter. Valid only when sending a message while reading mail. The text of the message is shifted to the right, and the string contained in the indentprefix variable is inserted as the leftmost characters of each line. If indentprefix is not set, a TAB character is inserted into each line.

~M [message-list]

Insert the listed messages, or the current message being read, including the header fields, into the letter. Valid only when sending a message while reading mail. The text of the message is shifted to the right, and the string contained in the indentprefix variable is inserted as the leftmost characters of each line. If indentprefix is not set, a TAB character is inserted into each line. Overrides the suppression of fields by the ignore command.

~p

Print the message being entered.

~q

Quit from input mode by simulating an interrupt. If the body of the message is not null, the partial message is saved in dead-letter. See DEAD in ENVIRONMENT VARIABLES for a description of this file.

~R

Mark message for return receipt.

~r file
~< file
~< ! shell-command

Read in the specified file. If the argument begins with an exclamation point (!), the rest of the string is taken as an arbitrary shell command and is executed, with the standard output inserted into the message.

~s string . . .

Set the subject line to string.

~t name . . .

Add the given names to the To list.

~v

Invoke a preferred screen editor on the partial message. The default visual editor is vi(1). See also VISUAL in ENVIRONMENT VARIABLES.

~w file

Write the message into the given file, without the header.

~x

Exit as with ~q except the message is not saved in dead-letter.

~| shell-command

Pipe the body of the message through the given shell-command. If the shell-command returns a successful exit status, the output of the command replaces the message.

Internal Variables

The following variables are internal variables. They may be imported from the execution environment or set using the set command at any time. The unset command may be used to erase variables.

allnet

All network names whose last component (login name) match are treated as identical. This causes the message-list message specifications to behave similarly. Disabled by default. See also the alternates command and the metoo and fuzzymatch variables.

alwaysignore

Ignore header fields with ignore everywhere, not just during print or type. Affects the save, Save, copy, Copy, top, pipe, and write commands, and the ~m and ~f tilde escapes. Enabled by default.

append

Upon termination, append messages to the end of the mbox file instead of prepending them. Although disabled by default, append is set in the system startup file (which can be suppressed with the -n command line option).

appenddeadletter

Append to the deadletter file rather than overwrite it. Although disabled by default, appenddeadletter is frequently set in the system startup file. See Starting Mail in USAGE above.

askbcc

Prompt for the Bcc list after the Subject is entered if it is not specified on the command line with the -b option. Disabled by default.

askcc

Prompt for the Cc list after the Subject is entered if it is not specified on the command line with the -c option. Disabled by default.

asksub

Prompt for subject if it is not specified on the command line with the -s option. Enabled by default.

autoinc

Automatically incorporate new messages into the current session as they arrive. This has an affect similar to issuing the inc command every time the command prompt is displayed. Disabled by default, but autoinc is set in the default system startup file for mailx; it is not set for /usr/ucb/mail or /usr/ucb/Mail.

autoprint

Enable automatic printing of messages after delete and undelete commands. Disabled by default.

bang

Enable the special-casing of exclamation points (!) in shell escape command lines as in vi(1). Disabled by default.

bsdcompat

Set automatically if mailx is invoked as mail or Mail. Causes mailx to use /etc/mail/Mail.rc as the system startup file. Changes the default pager to more(1).

cmd=shell-command

Set the default command for the pipe command. No default value.

conv=conversion

Convert uucp addresses to the specified address style, which can be either:

internet

This requires a mail delivery program conforming to the RFC822 standard for electronic mail addressing.

optimize

Remove loops in uucp(1C) address paths (typically generated by the reply command). No rerouting is performed; mail has no knowledge of UUCP routes or connections.

Conversion is disabled by default. See also sendmail(1M) and the -U command-line option.

crt[=number]

Pipe messages having more than number lines through the command specified by the value of the PAGER variable ( pg(1) or more(1) by default). If number is not specified, the current window size is used. Disabled by default.

debug

Enable verbose diagnostics for debugging. Messages are not delivered. Disabled by default.

dot

Take a period on a line by itself, or EOF during input from a terminal as end-of-file. Disabled by default, but dot is set in the system startup file (which can be suppressed with the -n command line option).

fcc

By default, mailx will treat any address containing a slash (/) character as a local send to file address. By unsetting this option, this behavior is disabled. Enabled by default.

flipr

Reverse the effect of the followup/Followup and reply/Reply command pairs. If both flipr and replyall are set, the effect is as if neither was set.

from

Extract the author listed in the header summary from the From: header instead of the UNIX From line. Enabled by default.

fuzzymatch

The from command searches for messages from the indicated sender. By default, the full sender address must be specified. By setting this option, only a sub-string of the sender address need be specified. Disabled by default.

escape=c

Substitute c for the ~ escape character. Takes effect with next message sent.

folder=directory

The directory for saving standard mail files. User-specified file names beginning with a plus (+) are expanded by preceding the file name with this directory name to obtain the real file name. If directory does not start with a slash (/), $HOME is prepended to it. There is no default for the folder variable. See also outfolder below.

header

Enable printing of the header summary when entering mailx. Enabled by default.

hold

Preserve all messages that are read in the mailbox instead of putting them in the standard mbox save file. Disabled by default.

ignore

Ignore interrupts while entering messages. Handy for noisy dial-up lines. Disabled by default.

ignoreeof

Ignore end-of-file during message input. Input must be terminated by a period (.) on a line by itself or by the ~. command. See also dot above. Disabled by default.

indentprefix=string

When indentprefix is set, string is used to mark indented lines from messages included with ~m. The default is a TAB character.

keep

When the mailbox is empty, truncate it to zero length instead of removing it. Disabled by default.

iprompt=string

The specified prompt string is displayed before each line on input is requested when sending a message.

keepsave

Keep messages that have been saved in other files in the mailbox instead of deleting them. Disabled by default.

makeremote

When replying to all recipients of a message, if an address does not include a machine name, it is assumed to be relative to the sender of the message. Normally not needed when dealing with hosts that support RFC822.

metoo

If your login appears as a recipient, do not delete it from the list. Disabled by default.

mustbang

Force all mail addresses to be in bang format.

onehop

When responding to a message that was originally sent to several recipients, the other recipient addresses are normally forced to be relative to the originating author's machine for the response. This flag disables alteration of the recipients' addresses, improving efficiency in a network where all machines can send directly to all other machines (that is, one hop away). Disabled by default.

outfolder

Locate the files used to record outgoing messages in the directory specified by the folder variable unless the path name is absolute. Disabled by default. See folder above and the Save, Copy, followup, and Followup commands.

page

Used with the pipe command to insert a form feed after each message sent through the pipe. Disabled by default.

pipeignore

Omit ignored header when outputting to the pipe command. Although disabled by default, pipeignore is frequently set in the system startup file. See Starting Mail in USAGE above.

postmark

Your real name to be included in the From line of messages you send. By default this is derived from the comment field in your passwd(4) file entry.

prompt=string

Set the command mode prompt to string. Default is “? ”, unless the bsdcompat variable is set, then the default is “&”.

quiet

Refrain from printing the opening message and version when entering mailx. Disabled by default.

record=file

Record all outgoing mail in file. Disabled by default. See also outfolder above.

replyall

Reverse the effect of the reply and Reply and followup and Followup commands. Although set by default, replayall is frequently unset in the system startup file. See flipr and Starting Mail in USAGE above.

returnaddr=string

The default sender address is that of the current user. This variable can be used to set the sender address to any arbitrary value. Set with caution.

save

Enable saving of messages in dead-letter on interrupt or delivery error. See DEAD for a description of this file. Enabled by default.

screen=number

Sets the number of lines in a screen-full of headers for the headers command. number must be a positive number.

The default is set according to baud rate or window size. With a baud rate less than 1200, number defaults to 5, if baud rate is exactly 1200, it defaults to 10. If you are in a window, number defaults to the default window size minus 4. Otherwise, the default is 20.

sendmail=shell-command

Alternate command for delivering messages. Note: In addition to the expected list of recipients, mail also passes the -i and -m, flags to the command. Since these flags are not appropriate to other commands, you may have to use a shell script that strips them from the arguments list before invoking the desired command. Default is /usr/bin/rmail.

sendwait

Wait for background mailer to finish before returning. Disabled by default.

showname

Causes the message header display to show the sender's real name (if known) rather than their mail address. Disabled by default, but showname is set in the /etc/mail/mailx.rc system startup file for mailx.

showto

When displaying the header summary and the message is from you, print the recipient's name instead of the author's name.

sign=string

The variable inserted into the text of a message when the ~a (autograph) command is given. No default (see also ~i in Tilde Escapes).

`

Sign=string

The variable inserted into the text of a message when the ~A command is given. No default (see also ~i in Tilde Escapes).

toplines=number

The number of lines of header to print with the top command. Default is 5.

verbose

Invoke sendmail(1M) with the -v flag.

translate

The name of a program to translate mail addresses. The program receives mail addresses as arguments. The program produces, on the standard output, lines containing the following data, in this order:

  • the postmark for the sender (see the postmark variable)

  • translated mail addresses, one per line, corresponding to the program's arguments. Each translated address will replace the corresponding address in the mail message being sent.

  • a line containing only y or n. if the line contains y the user will be asked to confirm that the message should be sent.

The translate program will be invoked for each mail message to be sent. If the program exits with a non-zero exit status, or fails to produce enough output, the message is not sent.

Large File Behavior

See largefile(5) for the description of the behavior of mailx when encountering files greater than or equal to 2 Gbyte ( 231 bytes).

Environment Variables

See environ(5) for descriptions of the following environment variables that affect the execution of mailx: HOME, LANG, LC_CTYPE, LC_TIME, LC_MESSAGES, NLSPATH, and TERM.

DEAD

The name of the file in which to save partial letters in case of untimely interrupt. Default is $HOME/dead.letter.

EDITOR

The command to run when the edit or ~e command is used. Default is ed(1).

LISTER

The command (and options) to use when listing the contents of the folder directory. The default is ls(1).

MAIL

The name of the initial mailbox file to read (in lieu of the standard system mailbox). The default is /var/mail/username .

MAILRC

The name of the startup file. Default is $HOME/.mailrc.

MAILX_HEAD

The specified string is included at the beginning of the body of each message that is sent.

MAILX_TAIL

The specified string is included at the end of the body of each message that is sent.

MBOX

The name of the file to save messages which have been read. The exit command overrides this function, as does saving the message explicitly in another file. Default is $HOME/mbox.

PAGER

The command to use as a filter for paginating output. This can also be used to specify the options to be used. Default is pg(1), or if the bsdcompat variable is set, the default is more(1). See Internal Variables.

SHELL

The name of a preferred command interpreter. Default is sh(1).

VISUAL

The name of a preferred screen editor. Default is vi(1).

Exit Status

When the -e option is specified, the following exit values are returned:

0

Mail was found.

>0

Mail was not found or an error occurred.

Otherwise, the following exit values are returned:

0

Successful completion. Notice that this status implies that all messages were sent, but it gives no assurances that any of them were actually delivered.

>0

An error occurred

Files

$HOME/.mailrc

personal startup file

$HOME/mbox

secondary storage file

$HOME/.Maillock

lock file to prevent multiple writers of system mailbox

/etc/mail/mailx.rc

optional system startup file for mailx only

/etc/mail/Mail.rc

BSD compatibility system-wide startup file for /usr/ucb/mail and /usr/ucb/Mail

/tmp/R[emqsx]*

temporary files

/usr/share/lib/mailx/mailx.help*

help message files

/var/mail/*

post office directory

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/core-os
Interface Stability
Committed
Standard

See Also

biff(1B), echo(1), ed(1), ex(1), fmt(1), ls(1), mail(1), mail(1B), mailcompat(1), more(1), pg(1), sh(1), uucp(1C), vacation(1), vi(1), newaliases(1M), sendmail(1M), aliases(4), passwd(4), attributes(5), environ(5), largefile(5), standards(5)

Notes

Where shell-command is shown as valid, arguments are not always allowed. Experimentation is recommended.

Internal variables imported from the execution environment cannot be unset.

The full internet addressing is not fully supported by mailx. The new standards need some time to settle down.

Replies do not always generate correct return addresses. Try resending the errant reply with onehop set.

mailx does not lock your record file. So, if you use a record file and send two or more messages simultaneously, lines from the messages may be interleaved in the record file.

The format for the alias command is a space-separated list of recipients, while the format for an alias in either the .forward or /etc/aliases is a comma-separated list.

To read mail on a workstation running Solaris 1.x when your mail server is running Solaris 2.x, first execute the mailcompat(1) program.