Not-So-Stupid Mail Tricks
Handy tips for Mail, the basic mail program.
It's more sophisticated than you may think!
Mail is a useful program that can do most stuff
that other fancier mailers do, if you take the time to figure out how.
This "not-so-stupid mail tricks" www page details this
underappreciated mail program.
Still to-do:
FAQ, command-line options, .mailrc, & options.
Some handy commands to use in mail, while
inputting your letter. The ~ commands have to be entered on the
first column of a new line.
- ~v
- Edit the letter you're typing with your
VISUAL editor. You cannot use the ~
commands while in the Visual Editor.
- ~e
- Edit the letter with basic EDITOR
editor. You cannot use the ~ commands while in the Basic
Editor.
- ~r filename
- Import text file filename into your letter. Can also
use ~< filename.
- ~w filename
- Write the letter you're typing out to text file
filename. Note that
~> filename will not work.
- ~m
- Quote the letter you are replying to. You probably want to put
the following line in your .mailrc file:
set indentprefix="> "
Otherwise, there will be a tab in front of each quoted line,
instead of a > ... You will want to edit your letter
(~e or ~v) to remove unnecessary lines and
put your replies in context.
Optionally, you can follow the ~m with a message
number to quote a letter other than the one you're replying to.
- ~f
- Similar to ~m, but quote a letter without prefixing
each line. Useful for forwarding messages. After reading the
message you want to forward, type
mail username
at the & prompt. Mail will ask for a subject, then
put you into input mode. If you wish, indicate that a forwarded
message follows, then type the ~f command.
Optionally, you can follow the ~f with a message
number to quote a letter other than the current one.
- ~c username
- Send a carbon-copy (cc) to user username when mailing
this letter.
- ~b username
- Send a "blind carbon-copy" to username - like a cc, but
doesn't show in headers. Usually used to send an archival copy
to onesself.
- ~p
- List what you have written in your letter so far.
- ~?
- Help with tilde commands.
- ~.
- End letter and send. Can also use ^D (control-D).
- ~q
- Abort letter and do not send. Can also use ^C^C.
The EDITOR and VISUAL environment variables tell
mail which editor to use when editing your letter.
Traditionally, in the old days of Unix, VISUAL was a full-screen
editor such as Vi, and EDITOR was a plain line-editor such as Ex.
Unless you're using a simple TTY, you probably won't have much use
for a line-mode-editor - you can set both variables to the same
value, or use different editors for different purposes (e.g. VISUAL
for a simple editor such as Pico and EDITOR for a more powerful
editor like Emacs).
To set the variables in the csh or tcsh shells, put something like
the following in your .login file:
setenv EDITOR ce
setenv VISUAL pico
Substituting your preferred editor for ce and pico, if you wish.
If you're using the sh or or bash/zsh shell, put the following lines
in your .profile file:
EDITOR=ce
export EDITOR
VISUAL=pico
export VISUAL
Again, substituting your preferred editor for ce and pico.
Note that other Unix programs such as newsreaders Tin, Nn, and Trn
use the VISUAL variable as their default editor.