LINUX CLASSES - EMAIL
What Other Mail Commands Can I Use?
Exiting the Mail Program
The q command entered at the next mail prompt ends the session and returns you to the shell prompt. But take note of the
messages that were printed on your way out: namely, Saved 1 message in /home/hermie/mbox and Held 2
messages in /var/mail/spool/hermie. For some odd reason, mail does not think it's a good idea to keep the mail
you've already read in the /var/spool/mail/hermie file, so it moves read mail to a separate file called mbox in your
own home directory.
To access the messages in the mbox file, you have to use the command
mail -f mbox
Kind of annoying, ain't it? But at least the mail program looks and acts the same regardless of which mail file you're working with.
Other Mail Commands
Let's get back into the mail program and have some fun with the two messages that we didn't read before with this scenario (again,
bold type represents your input):
Mail version 5.6 6/1/95. Type ? for help.
"/var/spool/mail/hermie": 1 message 1 new
>U 1 D.Rhodes@spam.net Mon Feb 10 15:37 "Make Money Fast!"
U 2 Chris@qwerty.com Mon Feb 10 15:37 "Tennis, Anyone?"
Date: Mon, 10 Feb 1997 15:37:52 -0500
Subject: Tennis, Anyone?
Wanna whack a few a 4:30 today? -Chris
Subject: Re: Tennis, Anyone?
Sure, I'll see you on the lower courts at 4:30.
U 1 D.Rhodes@spam.net Mon Feb 10 15:37 "Make Money Fast!"
>O 2 Chris@qwerty.com Mon Feb 10 15:37 "Tennis, Anyone?"
& delete 1
Saved 1 message in /home/hermie/mbox
We've introduced several new commands here, so let's take a closer look at the five operations that were performed in this mail
· As soon as I started the mail program, the mail headers were displayed, showing that both messages are marked U for unread. I
displayed message 2 by entering a 2 at the prompt.
· The reply command responded with an appropriate Subject line for message 2, Subject: Re: Tennis,
Anyone?, and waited for me to enter the text of my message to Chris. Pressing ctrl-D makes EOT appear and sends
· The header command displays the message headers. I've used it here to show the difference in the status flags. The >
indicates that message 2 is current, and the message is marked as O for old.
· I deleted the first message with delete 1 without even reading it, since the Subject line was rather dubious.
· And as a parting gesture, the q command told me that another message was squirreled away in that mbox file. At this point,
if I issued the mail command again, the system would respond:
No mail for hermie
Poor hermie. He needn't drink Draino, though--he can always send himself some more mail. ;-)
Previous Lesson: Reading Email
Next Lesson: Using Pine for Email
[ RETURN TO INDEX ]
Comments - most recent first
(Please feel free to answer questions posted by others!)
(07 Feb 2012, 20:59
I have a question, I hope to receive your help!
I wish to use the shell read the email and delete sendmail, not through
mail terminal operation, what method?
(06 Jan 2011, 13:20
Love it, nothing beats old school mail!
(14 Nov 2010, 17:35
I welcome your comments. However... I am puzzled by many people
who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn
all you can, ask questions if you like. But don't ask me to send what you already have. :-)
NO SPAM! If you post garbage, it will be deleted, and you will be banned.
by Bob Rankin
All rights reserved - Redistribution is allowed only with permission.