Communicating via Mail
=============================================================================
Overview: One of the most exciting aspects of using computers is how it
enables people to communicate in new and efficient ways, and
electronic mail, or email, is the main way this is done. We
describe email as it is implemented in many UNIX systems, and
specifically here at Canisius.
=============================================================================
Section Topics
------- ------
Usernames and Internet addresses
How to send a message to someone
Reading your Mail
Mail commands
Mailboxes
Aliases and mail groups
Mail etiquette
Usernames and Internet addresses
--------------------------------
Sending mail is very easy. First you have to know who you are sending to,
and that means you must find out the person's username. If you only know
someone's real name, such as "Joe Stanwick", you can find out their username by
using the finger command:
% finger Joe
This command will find all users whose username is "joe" or who have "Joe" in
their "in real life:" field of the user database. (This is set by the system
operator and cannot be changed by a user.)
One last word about usernames: you may want to send mail to someone on
a different computer or a different campus via the Internet. This requires that
you know their username AND their computer's name, and there are no simple ways
to find these out unless they just tell you. The syntax of these names is
username @ computername
or
username @ computername . networkname
For example, you can send to someone on the CCVMSA computer here at Canisius,
although you don't need to specify the network's name:
meyer@ccvmsa
However, if this computer were off campus, you would need a longer name, such as
joseph@gandalf.canisius.edu
The computer's name is "gandalf" and the network name is the rest of the name,
with parts separated by dots. Do not worry about the format of this address
right now. Just understand that you have to be told what this name is since
on-line ways of finding people given their "real life" names are very weak at
present.
How to send a message to someone
--------------------------------
There are two ways to send mail: interactively and non-interactively.
These actually refer to the methods by which the message is created. The
interactive method is commonest, where you compose your mail message as you
send the mail.
To start this type of mail, do
% mail meyer
where "meyer" is a UNIX username of the person whom you wish to send to.
Remember that this could also be a network address.
UNIX next asks you for a subject line. Type in something short but mean-
ingful, like
Sorry I forgot our advising appointment this AM
It is considered appropriate, even proper, to use shortcuts and abbreviations
during electronic communications. They make typing faster and even shorten
the length of mail messages. For example, AM above refers obviously to
"morning". You may run across more of these later, BTW -- "By the Way" or
LOL -- "Laugh out loud". Also, most people suspend their criticism of spelling
errors with electronic communications since it is impossible to spellcheck as
you talk on a bulletin board or send mail, and even the best of us make typing
errors.
The subject line is important because it appears on the summary page of
incoming mail messages so that the recipient can gauge the importance of the
message quickly. Sometimes, you may send a message that consists only of the
subject line. UNIX allows this.
Normally, you would write a longer message. Just type in your message,
one line at a time. If you make a mistake on a line, you can use backspace or
delete keys to fix them, but generally you cannot go back to a previous line.
There are a number of things that mail allows you to do when you type in
a message. These commands begin with the tilde character, such as ~r, which
reads and includes a file into your mail message. Be wary of starting a line
with a tilde character, lest you unwittingly give a command to UNIX mail!
When you are done entering lines, press CONTROL-D, which, as you might
remember, is the standard "end of file" signal to UNIX. You will also see
a cc: prompt come up on your screen. This is the carbon copy recipient,
in case you want to send a copy of the message to some other user, or even
yourself for your own records. If you don't want to, just press RETURN.
After you finish entering your message, UNIX will attempt to send the
mail, and you will see cryptic messages telling you that UNIX is connecting
to local and sending the mail. Under normal circumstances, UNIX will send
the mail so fast that the other person can read it within a minute or so.
However, network mail may not be so fast, due to various networks being
down temporarily. If the Canisius UNIX computer cannot send mail right away,
it defers it till later. Occasionally, our computer cannot send the mail at
all, so it returns it to you with a message saying it is undeliverable.
Check your network address first, then contact a professor in Computer
Science.
The non-interactive way involves creating a file with your message in it
and then using input redirection to hand this file over to mail to send.
(Redirection is mentioned in some detail in the "compile" lesson.) Here's
how to do this. First create a file with your message in it. Then send it:
% vi mymessage
% mail meyer < mymessage
The less-than sign is the input redirection symbol, saying to take the contents
out of file "mymessage" and hand them to mail. Doing this does not alter
file "mymessage".
The non-interactive way does not allow you to specify a subject line or
carbon copy recipients. However, you can mail the same message to a number of
users at once:
% mail meyer joe kathy < mymessage
They will each get a copy.
Reading your Mail
-----------------
When you log on, you may see the message
You have new mail
which means that someone has sent you some mail that you haven't read. Also,
you may receive new mail during your computer session. The computer will beep
and give you a brief message saying that new mail has arrived.
To receive mail, just type
% mail
UNIX shows you a numbered list of letters which are waiting to be read. Type
the number of the message to read it. Here is a simple display of what you
might see:
> 1 smith Wed June 1 11:45 34/1327 Hi there from an old fr
2 mcgregor Tue May 31 13:31 5/563 Where is that report?
&
The prompt changes to the ampersand inside mail. Just type 2 to read the
second message (which looks important). When you read a message it moves from
your current mailbox to your old mailbox, unless you specifically delete it.
As you read a message, you may wonder about all those weird lines at the
top of the message, detailing the recipient, the path, time, etc. Mail puts
an extensive header on each message so that the sender can be identified and
the network path can be reconstructed, in case you wish to reply. When a mail
message goes through many networks, it often accumulates several headers,
which can occupy more than a screenful. Most UNIX users just ignore the header,
unless something goes wrong.
Mail commands
-------------
There are many mail commands accessible from the ampersand. You can see
the list of them by typing the question mark. Here is that list:
cd [directory] chdir to directory or home if none given
d [message list] delete messages
e [message list] edit messages
f [message list] show from lines of messages
h print out active message headers
m [user list] mail to specific users
n goto and type next message
p [message list] print messages
pre [message list] make messages go back to system mailbox
q quit, saving unresolved messages in mbox
r [message list] reply to sender (only) of messages
R [message list] reply to sender and all recipients of messages
s [message list] file append messages to file
t [message list] type messages (same as print)
top [message list] show top lines of messages
u [message list] undelete messages
v [message list] edit messages with display editor
w [message list] file append messages to file, without from line
x quit, do not change system mailbox
z [-] display next [previous] page of headers
! shell escape
Only a subset of these commands will be used often. Here's a brief discussion
of a few of them.
You can delete a message from your mailbox by typing d and the message
number:
& d 17
or you can delete a range of messages by using a dash between message numbers:
& d 1-4
These messages aren't actually deleted until you type "q" to exit mail and
save changes to your mailbox, which is the file where your incoming messages
are stored. The "x" command quits without saving changes to your mailbox,
in case you made a mistake during deletion.
Another common thing is to reply to someone. After you read their message,
just type "r" to reply. The subject line is the old subject line with a Re:
prepended to it. ("Re:" means "regarding" and is standard on business letters.)
Sometimes you wish to save a mail message to a file. Use the "s" command:
& s 17 joe.message
This allows you to print it out or include it in some other document. All the
headers are placed in the file, too, so you must edit those out, especially if
the message is a program. If you don't edit out the headers, you'll get syntax
errors from your compiler.
When you are very popular and there are too many message headers on your
screen, you can use the z and z- commands to move back and forward in the
headers.
Mailboxes
---------
A mailbox is just a UNIX file that contains mail messages. All messages are
stored as ASCII characters; the presence of the mail headers mark off the
messages from one another. (Proper UNIX terminology calles these mailboxes
"folders" but that seems very confusing, especially since folders are the Mac-
intosh name for directories.)
When someone sends you mail, it goes into a mailbox file in the directory
/var/spool/mail/yourname
where "yourname" is your username. This is the file that is checked when you
log on to see if you have new mail. If you have just looked at the headers
without reading the actual mail messages, UNIX will just say
You have mail
without the qualifier "new". Thus, you can tell if someone has sent you
any messages since you last looked at the headers.
As you read your messages, they are marked for removal from the main
mailbox. If you read a message, but do not delete or save it, it will be put
into another mailbox file called "mbox" which sits in your home directory.
Occasionally, this mailbox will get clogged with old, saved messages. Period-
ically, clean out your mbox and decide what to keep. You can do this by using
the -f option on the mail command which tells mail to use the mbox file instead:
% mail -f
The -f usually precedes a mailbox filename, so mail can process any file that
contains mail messages. If there is no filename after -f, then your mbox file
is used. Actually, you could edit or change this file or even delete it as you
wish. However, if you "screw up" the message headers, the mail command may not
be able to find the various mail messages in it, so be careful!
Notice in the list of commands that there is a "cd" command to change
directory. You can move around in your directory tree and save messages in
almost any directory and file. Anytime you specify to save a message in a file,
and the file does not exist, UNIX creates it, and that file becomes a mailbox
file. For example
& s 1-5 boss.msgs
saves messages 1 through 5 into a file called "boss.msgs". Now you can process
that file using mail whenever you want:
% mail -f boss.msgs
You can also append new messages onto the end of an existing mailbox by simply
using the "s" command with an existing file's name:
& s 10 boss.msgs
Aliases and mail groups
-----------------------
Some internet addresses are long and difficult to remember, and sometimes
you may want to give a nickname or alias to a user whom you mail frequently.
You can set up an alias to accomplish this, and also to form your own mail
group.
In your home directory is a file called .mailrc (notice the leading dot).
In UNIX any file whose name begins with the dot and ends with "rc" is usually
a startup file for some command or system. The "rc" actually stands for "run
commands" which are commands that the system runs when it starts up the sub-
system. Thus mail uses .mailrc, the Cshell uses .cshrc, X Windows has its
.xinitrc and vi uses .exrc. .exrc??? The use of "ex" instead of "vi" is
due to the fact that vi is built on top of an earlier line editor called "ex".
Here's what an alias line would look like in your .mailrc:
alias mom xyz4732@gandalf.wustl.wu.edu
Whenever you "mail mom", the "mom" is translated into the awful and unmemoriz-
able network address "xyz4732@gandalf.wustl.wu.edu".
Here's a mail group set up in your .mailrc file:
alias friends john mark sue kathy tim
Whenever you send anything to "friends" the same message is sent to each of
john, mark, sue, kathy and tim.
Finally you can just rename somebody:
alias mark meyer
You can mail to "mark" and it will reach meyer.
There are many other things you can put into your .mailrc file. Here's
a very brief run-down. If you want to have mail prompt you for a cc line,
put the following in:
set askcc
Or you can turn off this prompting:
unset askcc
Likewise, "set ask" turns on prompting for the Subject line.
You can have mail keep a record of all your outgoing messages by doing
set record=somefilename
where "somefilename" is a file's name in which these copies of outgoing letters
will be stored.
When you read a very long message, a pager is used. This is usually less
or more, but you can change it:
set PAGER=/usr/local/bin/less
For more details, look at the man page for mail.
Finally, notification of incoming mail often bothers some users because it
displays a part of the message on their screen, no matter what they are doing.
You can turn this off by using the "biff" command, which is NOT in your .mailrc
file, but rather goes into your .login file.
biff n
If you want to be notified, you can put "biff y" in there instead. This is a
regular UNIX command so you can issue it anytime from the prompt depending on
whether you want to be notified of mail or not.
Mail etiquette
--------------
Last but not least is the issue of proper behavior when using electronic
communication. Some thought must be given to careful, considerate and effective
communication because electronic media are substantially different than other
forms.
First, email is faster than the postal service (often referred to as "snail
mail") so people often react quickly, especially if they are upset. If you are
upset, you might consider not responding to the other party for a couple hours,
until you have had time to cool off.
Second, email is somewhat impersonal, so subtle cues such as those provided
by body language or tone of voice are absent. All that the other person has is
your typewritten words and if these could be construed in the wrong way, then
your intentions may be misunderstood. Actually, email forces us to be very
clear and precise in our use of written language, so it is good practice for
improving our writing skills.
Third, not all people are good spellers and even the best have troubles,
or they make typos. Do not be critical of spelling or grammar in email, al-
though formal written documents, like papers or programs, should not be treated
in the same way. Just as you do not have to be a great orator when you speak on
the telephone, you do not have to be perfect in email, but that does not mean
that slovenly habits should become the norm.
Fourth, email is communication like any other, and its impersonal nature
does not actually permit you to suspend normal rules of good behavior, even
though it may seem like you are hiding behind the keyboard. The anonymity is
illusory, since each mail message is stamped with the sender's username. (This
is also a good reason never to let anyone else use your username for any
purpose!) When you communicate by email, do not be impolite or use inappro-
priate language. Do not harass somebody in any way, either by sending them too
many unwanted email messages or by using offensive images, language or content
in your email. Just pretend that whatever you send will be stored in a system
file for later inspection! (In reality there are legal rights of privacy that
you have, but the system administrator also has legal rights to inspect mail
if foul play is suspected, and recent court cases have upheld use of email as
a form of evidence.) In summary, simply remember that you should not do with
email anything that would be considered immoral or unethical with any other
method of communication, such as telephone calls or personal letters.
There are a variety of tricks that people use to add emphasis to their
email. You can surround important words or phrases with underscores or
asterisks to set them off, since you cannot actually underline something on
the terminal screen. You can also capitalize words. "Do *NOT* turn off the
power switch, for _any_ reason!"
Another favorite device with emailers is the "smiley" which is a caricature
of a smiley face, done with ANSI characters. You must sometimes use your
imagination and turn your head to the left. Here are a few popular ones:
:-) Standard happy face :-( sad face
>:-| angry face ;-) wink
:-O open mouth, surprise! |-) closed-eye smile
There have been lists of thousands of smiley faces published.
If you get into a heated discussion with another UNIX user, it may be said
that you are "flaming" or that this line of discussion is a "flame", probably
referring to using a flame thrower to scorch your opponent with heated words.
Flaming is often considered childish or a waste of network bandwidth, but that
hasn't stopped it! As always be careful and considerate, and remember to shed
light, not heat, on the subject!
As mentioned earlier, various abbreviation are used to shorten typing:
BTW -- by the way
LOL -- laugh out loud
OIC -- Oh, I see
OO -- over and out
Undoubtedly you will encounter many more, and they are even making their way
into the popular media like TV and newspapers. An excellent book has recently
been published called "The Elements of Email Style" by David Angell and Brent
Heslop which discusses effective writing and communication with email. It is a
take off of Strunk and White's famous "The Elements of Style" and, sneakily, it
teaches you about good writing while you are interested in just electronic mail.