Notice! This document is currently in Archived status.
The content of this document may be incorrect or out dated.

MailX Tutorial

When you start to read your mail, you may not have any messages. The easiest thing to do is send YOURSELF mail. To do this follow the examples below.

EXAMPLE:

% mailx Your-login            <-- This starts the process of 
				  entering a message.
  subject:                    <-- Subject line of message, this is optional.
  blah blah blah              <-- Body of 
  this is a test.                 your message.
  .                           <-- A single period ends your message.

EOT                           <-- End of Transmission signal.
%

To send the mail message, I typed a period then a "return". You can also send mail by typing a "control-d", which is holding down the "control" and the "d" key at the same time. You will then receive the EOT (end of transmission signal).

Once you have sent the mail, it is GONE, you can't get it back! My login is stacey and I just sent myself e-mail. If you were to send mail to someone else, you do the same thing, except you use their login. Note that although my mail alias is stacey@ecn.purdue.edu, anyone who is on an ECN machine can just send mail to stacey without specifying the domain name. However, if you are over at ITaP, you would need to be more explicit, and use stacey@ecn. If you are OFF CAMPUS, then you need to use the complete mail alias (stacey@ecn.purdue.edu).

If you wish to send mail to multiple people, just type their login names. If I wished to send mail to Steve Clark (steve@bptech.com) and Dave Carmichael (carmicha@ecn.purdue.edu) at the same time, I could, like this:

 

% mailx  steve@bptech.com  carmicha
 subject:  Hi!

Note that I didn't have to specify Dave's @ecn.purdue.edu address because he and I are both at ECN. But, Steve is off campus, so I need to be more explicit.

You can also use "carbon copy" and "blind carbon copy" to let someone other than the person to whom the mail is directed, receive a copy. The easiest way for me to send mail to Steve Clark, and carbon copy the message to Dave, and send myself a secret copy is to type this:

 

% mailx steve@bptech.com
 subject: Hi!
 ~c carmicha
 ~b stacey

The tilde ~ has to be the first character typed in a line, after the subject line and before you send the message. You may also type ~ and be prompted for each item.

 

% mailx steve@bptech.com
 subject: Hi!
 I just wanted to tell you something important!
 ~h
 To: steve@bptech.com,
 Cc: 
 Bcc:
 Subject: Hi!
 (continue)

After I am prompted, I can type in an e-mail login@address, or change the subject line. The difference between a Carbon Copy (Cc:) and Blind Carbon Copy (Bcc:) is that when a person is carbon copied, their address will be displayed to all of the email recipients, while recipients of a Blind Carbon Copy will not be able to see who else the email has been sent to.

Let's look at some examples of commands you can do with mailx. First, I type mailx to read my mail:

 

% mailx
mailx version 5.0 Fri Mar 18 15:04:31 PST 1994  Type ? for help.
"/var/mail/stacey": 13 messages 3 new 1 unread
 O 1 0000-Admin(0000)    Wed Mar 20 )2:02    90/4325  Rdist summary
 O 2 AICHE               Wed Mar 20 07:56    24/668   ka9 quota
 O 3 B. Catherine Kozlo  Wed Mar 20 09:57    30/984   known problems
 O 4 Douglas M Gross     Wed Mar 20 11:48    32/831   lpmpc
 O 5 Kyler B Laird       Wed Mar 20 12:25    62/2132  Re: slirp
 O 6 ChE Support Queue   Wed Mar 20 12:30    25/1300  New messages in cheq queu
 O 7 B. Catherine Kozlo  Wed Mar 20 12:35    28/974   AnswerBook
 O 8 ChE Support Queue   Wed Mar 20 12:36    36/1081  Re: Re: lpmpc - change ho 
 O 9 Douglas M. Gross    Wed Mar 20 14:00    63/2048  Re: lpmpc - change home d
 U10 Diana_K._Dick_at_Z  Wed Mar 20 14:14    39/1497  Re: good morning!
>N11 Kyler B Laird       Wed Mar 20 14:14    31/1466  pdfread PATH change
 N12 Marlesa A. Roney    Wed Mar 20 14:16    60/2044  Re: hi
 N13 Thomas R. Statnick  Wed Mar 20 14:18   151/6608  GTE proposes ISDN tariff
?

If I ever want to see a listing like the above again, I can type ? h and it will print out one screen full of the current message headers. Let's look at the information listed on the last line:

 

 N13 Thomas R. Statnick  Wed Mar 20 14:18   151/6608  GTE proposes ISDN tariff

 

N				New Mail (O= old, U= unread) 
13				This is message number 13
Thomas R Statnick		The sender of the e-mail
Wed Mar 20			The date the mail arrived
14:18				The time the mail arrived
151/6608			The size of the mail
GTE proposes ISDN tariff	The SUBJECT message

So, I know lots of information, before I even read my first message. If I hit return or type 11, I will read message #11 because the > sign is pointing at message 11. If I wish to read the last message, I could type 13

 

? 13
 Message 13:
 From trs@ecn.purdue.edu Wed Mar 20 14:18 EST 1996
 To: ecnstaff@ecn.purdue.edu
 Subject: GTE proposes ISDN tariff change for Lafayette CO's.
 Mime-Version: 1.0
 Date: WEd, 20 Mar 1996 14:17:55 EST
 From: Thomas R Statnick <trs@ecn.purdue.edu> 

<message would appear here>
?

I might wish to reply to the sender with an answer. I can do this by typing ? r and the computer will fill in the mail address, and repeat the "subject" line, so I don't have to bother typing all that.

 

? r
To: trs@ecn.purdue.edu
Subject: GTE proposes ISDN tariff change for Lafayette CO's.

I also like to read in the message, to include the original text in the reply. I can use ~ to read in the current message for "trs" or I can type ~m and the message will be copied in, but right shifted by a tab, so it is indented, and easy to tell that it is separate from my new message. If for some reason I make a mistake, I can edit the file with vi by typing ~v or I can quit the message, and start over by typing ~q . Before I send the mail message, another thing I like to do is PREVIEW the mail message, before I send it, to make sure I did everything exactly like I wanted to do. I type ~p and the message and headers print out for me! Then I can send the message with a control-d, or by typing a period.

If you forget the above commands, you can type ~? and a list will be displayed.

~ Escapes

~~			Quote a single tilde
~a,~A			Autograph (insert 'sign','Sign' varable)
~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 sight-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			Read 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

Then you can continue typing, because you are still inside the body of the mail message. Send the message as usual, by typing control-d or a period on a line by itself.

Next you need to decide what to do with that mail message. You can type d and delete the message (while you are still in the same mail session, you can undelete messages with u). You can type S and the current message will be saved in a file called "trs", since the sender of the message is "trs". You can type w filename at the ? prompt; and the file will be stored in a file called filename. Once it is saved as a file, you can print the file. lp -d printername filename, as in lp -d ka9 file. Or if you don't do anything, when you exit mailx, the message will be appended to the file mbox. If you accumulate a bunch of mail in your mbox file, you can completely remove that file by typing at your system prompt, rm mbox or you can use vi or your favorite editor, to selectively remove messages from the mbox file.

There is another file, a control file, called .mailrc that can be used to set certain parameters with mailx. A sample .mailrc file might look like this:

 

	set autoprint
	set crt 22
	set PAGER=/usr/ucb/more
	set metoo
	alias chasey wn9nbt
	alias ssung ssung@eng2.uconn.edu
	# list of ChE class acounts:
	alias classes che450 che366 che211 che348 che205 che320 che378
	alias steve steve@bptech.com
	alias Us steve stacey

When you type in an alias, the line is allowed to continue (wrap) until you hit the Unix character limit. You can also make lines look prettier by continuing the line with the backslash (\\) characters. If a line starts with a pound sign (#) it is treated as a comment line. You can type man mailx to see all the various options that you may set

An explanation for the items I have listed in the sample .mailrc are:

 


If you set an alias that is the same as a local login, like I set "steve", then that mail alias supercedes any ECN mail. So when I type mailx steve I won't send mail to "steve@ecn.purdue.edu", because I have set the alias "steve" to be "steve@bptech.com".

Once you create a .mailrc by using vi or your favorite editor, it will be invoked every time you run mailx. Remember that files that start with a period are hidden, unless you invoke the -a option to ls.

Note: if you see a prompt of % that means you are at the UNIX prompt. If you see a prompt of ? that means you are at a mailx prompt. If you see no prompt, then you are in the body of the mail message

 

Mailx commands (execute at ? prompt)


    1. autoprint After you type d the next messages prints
  • crt Sets the screen length to 22 lines.
  • PAGER If the message is long, more will be invoked. You may press Return to get one more line press Space Bar to get one more screen. Type q to quit and get back to the mailx prompt.
  • metoo If you send mail to an alias you are in, you will get mail too.
  • alias Use an alias to set one word to mean a login or many logins. Case matters, so be consistent when typing captial letters!
  • alias Us You may set an alias to include another alias, so mailx Us would append to mailx steve@bptech.com, stacy. Make sure you don't use quotes (") because aliases "steve stacey" won't work.
      • delete [msglist] delete messages
    • d 1-4 delete messages 1,2,3,4
    • dp,dt [msglist] delete messages and type next message
    • h [message] print page of active message headers
    • help, ? print help message
    • hold,pre [msglist] hold/preserve messages in mailbox
    • inc incorporate new messages into current session
    • m user mail to specific user
    • n [message] goto and type next message
    • p,t [msglist] print messages
    • P,T [msglist] print messages with all headers
    • q quit, preserving unread messages
    • r [msglist] reply to authors (only) of the messages
    • R [message] reply to the authors and recipients of the msg
    • s [message] file save (appending) messages to file
    • S [msglist] save messages to file named after author
    • u [msglist] restore deleted messages
    • v [msglist] edit list with $VISUAL editor
    • w [msglist] file write messages without headers
    • x,exit quit, reserving all messages
    • z[+/-] display next [last] page of 10 headers

       

    • [msglist] is optional. It specifies messages by number, author, suject or type. The default is the current message.

Last modified: 2007/05/22 12:40:15.783000 GMT-4 by Unknown
Created: 2007/05/22 12:40:15.783000 GMT-4 by brian.r.brinegar.1.

Categories

Search

Type in a few keywords describing what information you are looking for in the text box below.

Admin Options: Edit this Document