1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 99.2beta8 (1.46)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>10. Mail</TITLE>
<META NAME="description" CONTENT="10. Mail">
<META NAME="keywords" CONTENT="rute">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v99.2beta8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="rute.css">
<LINK REL="next" HREF="node14.html">
<LINK REL="previous" HREF="node12.html">
<LINK REL="up" HREF="rute.html">
<LINK REL="next" HREF="node14.html">
</HEAD>
<BODY BGCOLOR=#FFFFFF >
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR><TD align=left bgcolor="#000000">
<FONT COLOR=white>
<A HREF="http://www.icon.co.za/~psheer/rute-purchase.html"><FONT COLOR=white>Purchase</FONT></A>
</FONT>
</TD><TD align=center bgcolor="#000000">
<FONT COLOR=white>
Copyright © 2002 Paul Sheer. <A HREF="copying.html"><FONT COLOR=white>Click here for copying permissions.</FONT></A>
</FONT>
</TD><TD align=right bgcolor="#000000">
<FONT COLOR=white>
<A HREF="http://www.icon.co.za/~psheer/rute-home.html"><FONT COLOR=white>Home</FONT></A>
</FONT>
</TD></TR>
<TR><TD colspan=2 align=left bgcolor="#ECEBF4">
<IMG SRC="va-btn-small-light-60.png">
</TD><TD align=right bgcolor="#ECEBF4">
<IMG SRC="sflogo2-steel-60.png">
</TD></TR>
</TABLE><BR>
<!--Navigation Panel-->
<A NAME="tex2html1916"
HREF="node14.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
<A NAME="tex2html1912"
HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
<A NAME="tex2html1906"
HREF="node12.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
<A NAME="tex2html1914"
HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html1917"
HREF="node14.html">11. User Accounts and</A>
<B> Up:</B> <A NAME="tex2html1913"
HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html1907"
HREF="node12.html">9. Processes, Environment Variables</A>
  <B> <A NAME="tex2html1915"
HREF="node1.html">Contents</A></B>
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL>
<LI><A NAME="tex2html1918"
HREF="#SECTION001310000000000000000">10.1 Sending and Reading Mail</A>
<LI><A NAME="tex2html1919"
HREF="#SECTION001320000000000000000">10.2 The SMTP Protocol -- Sending Mail Raw to Port <TT>
<FONT COLOR="#0000ff">25</FONT></TT></A>
</UL>
<!--End of Table of Child-Links-->
<HR>
<H1><A NAME="SECTION001300000000000000000">
10. Mail</A>
</H1>
<P>
<A NAME="chap:mailclient"></A>
<P>
<I>Electronic Mail</I>, or <I>e</I>mail, is the way most people first come into
contact with the Internet. Although you may have used email in a graphical environment,
here we show you how mail was first intended to be used on a multiuser system.
To a large extent what applies here is really what is going on in the
background of any system that supports mail.
<P>
A mail message is a block of text sent from one user to another,
using some mail command or mailer program. A mail
message will usually also be accompanied by a <I>subject</I>
explaining what the mail is about. The idea of mail is that a
message can be sent to someone even though he may not be logged
in at the time and the mail will be stored for him until he is
around to read it. An email address is probably familiar to you,
for example: <TT>
<FONT COLOR="#0000ff">bruce@kangeroo.co.au</FONT></TT>. This means that
<TT>
<FONT COLOR="#0000ff">bruce</FONT></TT> has a user account on a computer called
<TT>
<FONT COLOR="#0000ff">kangeroo.co.au</FONT></TT>, which often means that he can log in as
<TT>
<FONT COLOR="#0000ff">bruce</FONT></TT> on that machine. The text after the <TT>
<FONT COLOR="#0000ff">@</FONT></TT> is always
the name of the machine. Today's Internet does not obey this
exactly, but there is always a machine that <TT>
<FONT COLOR="#0000ff">bruce</FONT></TT>
<I>does</I> have an account on where mail is eventually sent.
<FONT COLOR="#ffa500">[That machine is also usually a U<SMALL>NIX</SMALL> machine.]</FONT>
<P>
Sometimes email addresses are written in a more user-friendly
form like <TT>
<FONT COLOR="#0000ff">Bruce Wallaby <bruce@kangeroo.co.au></FONT></TT> or
<TT>
<FONT COLOR="#0000ff">bruce@kangeroo.co.au (Bruce Wallaby)</FONT></TT>. In this case,
the surrounding characters are purely cosmetic;
only <TT>
<FONT COLOR="#0000ff">bruce@kangeroo.co.au</FONT></TT> is ever used.
<P>
When mail is received for you (from another user on the system or from a
user from another system) it is appended to the file <TT>
<FONT COLOR="#0000ff">/var/spool/mail/<username></FONT></TT>
called the <I>mail file</I> or <I>mailbox file</I>;
<TT>
<FONT COLOR="#0000ff"><username></FONT></TT> is your login name. You then run some program that interprets your mail file, allowing
you to browse the file as a sequence of mail messages and read and reply to
them.
<P>
An actual addition to your mail file might look like this:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red size="-1">
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>10</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>15</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>20</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>25</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>30</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>35</code></font><code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue size="-1">
<code>From mands@inetafrica.com Mon Jun 1 21:20:21 1998</code><br>
<code>Return-Path: <mands@inetafrica.com></code><br>
<code>Received: from pizza.cranzgot.co.za (root@pizza.cranzgot.co.za [192.168.2.254])</code><br>
<code> by onion.cranzgot.co.za (8.8.7/8.8.7) with ESMTP id VAA11942</code><br>
<code> for <psheer@cranzgot.co.za>; Mon, 1 Jun 1998 21:20:20 +0200</code><br>
<code>Received: from mail450.icon.co.za (mail450.icon.co.za [196.26.208.3])</code><br>
<code> by pizza.cranzgot.co.za (8.8.5/8.8.5) with ESMTP id VAA19357</code><br>
<code> for <psheer@cranzgot.co.za>; Mon, 1 Jun 1998 21:17:06 +0200</code><br>
<code>Received: from smtp02.inetafrica.com (smtp02.inetafrica.com [196.7.0.140])</code><br>
<code> by mail450.icon.co.za (8.8.8/8.8.8) with SMTP id VAA02315</code><br>
<code> for <psheer@cranzgot.co.za>; Mon, 1 Jun 1998 21:24:21 +0200 (GMT)</code><br>
<code>Received: from default [196.31.19.216] (fullmoon)</code><br>
<code> by smtp02.inetafrica.com with smtp (Exim 1.73 #1)</code><br>
<code> id 0ygTDL-00041u-00; Mon, 1 Jun 1998 13:57:20 +0200</code><br>
<code>Message-ID: <357296DF.60A3@inetafrica.com></code><br>
<code>Date: Mon, 01 Jun 1998 13:56:15 +0200</code><br>
<code>From: a person <mands@inetafrica.com></code><br>
<code>Reply-To: mands@inetafrica.com</code><br>
<code>Organization: private</code><br>
<code>X-Mailer: Mozilla 3.01 (Win95; I)</code><br>
<code>MIME-Version: 1.0</code><br>
<code>To: paul sheer <psheer@cranzgot.co.za></code><br>
<code>Subject: hello</code><br>
<code>Content-Type: text/plain; charset=us-ascii</code><br>
<code>Content-Transfer-Encoding: 7bit</code><br>
<code>Status: RO</code><br>
<code>X-Status: A</code><br>
<code> </code><br>
<code>hey paul</code><br>
<code>its me</code><br>
<code>how r u doing</code><br>
<code>i am well</code><br>
<code>what u been upot</code><br>
<code>hows life</code><br>
<code>hope your well</code><br>
<code>amanda</code><br>
</FONT></TD></TR></TABLE><P>
<P>
Each mail message begins with a <TT>
<FONT COLOR="#0000ff">From</FONT></TT> at the beginning
of a line, followed by a space. Then comes the <I>mail header</I>,
explaining where the message was routed from to get
to your mailbox, who sent the message, where replies should
go, the subject of the mail, and various other <I>mail header fields</I>. Above,
the header is longer than the mail messages. Examine the header
carefully.
<P>
The header ends with the first blank line. The message itself
(or <I>body</I>) starts right after. The next header in the file
will once again start with a <TT>
<FONT COLOR="#0000ff">From</FONT></TT>. <TT>
<FONT COLOR="#0000ff">From</FONT></TT>s on
the beginning of a line <I>never</I> exist within the body.
If they do, the mailbox is considered to be corrupt.
<P>
Some mail readers store their messages in a different format.
However the above format (called the <I>mbox</I> format) is the
most common for U<SMALL>NIX</SMALL>. Of interest is a format called <I>Maildir</I>,
which is one format that does <I>not</I> store mail messages
in a single contiguous file. Instead, <I>Maildir</I> stores each message
as a separate file within a directory. The name of the directory is
then considered to be the mailbox ``file''; by default Maildir uses a
directory <TT>
<FONT COLOR="#0000ff">Maildir</FONT></TT> within the user's home directory.
<P>
<H1><A NAME="SECTION001310000000000000000">
10.1 Sending and Reading Mail</A>
</H1>
<P>
The simplest way to send mail is to use the <TT>
<FONT COLOR="#0000ff">mail</FONT></TT> command.
Type <TT>
<FONT COLOR="#0000ff">mail
-s "hello there" <username></FONT></TT>. The <TT>
<FONT COLOR="#0000ff">mail</FONT></TT>
program will then wait for you to type out your message. When you are
finished, enter a <TT>
<FONT COLOR="#0000ff">.</FONT></TT> on its own on a single line. The
user name will be another user on your system. If no one else is
on your system, then send mail to <TT>
<FONT COLOR="#0000ff">root</FONT></TT> with
<TT>
<FONT COLOR="#0000ff">mail -s "Hello there" root</FONT></TT> or <TT>
<FONT COLOR="#0000ff">mail -s "Hello there" root@localhost</FONT></TT> (if
the @ is not present, then the local machine, <TT>
<FONT COLOR="#0000ff">localhost</FONT></TT>, is implied).
Sending files over email is discussed in Section <A HREF="node15.html#sec:filesoveremail">12.6</A>.
<P>
You can use <TT>
<FONT COLOR="#0000ff">mail</FONT></TT> to view your mailbox. This is a
primitive utility in comparison with modern graphical mail readers
but is probably the only mail reader that can handle arbitrarily
sized mailboxes. Sometimes you may get a mailbox that is over a
gigabyte in size, and <TT>
<FONT COLOR="#0000ff">mail</FONT></TT> is the only way to delete
messages from it. To view your mailbox, type <TT>
<FONT COLOR="#0000ff">mail</FONT></TT>, and then
<TT>
<FONT COLOR="#0000ff">z</FONT></TT> to read your next window of messages, and <TT>
<FONT COLOR="#0000ff">z-</FONT></TT> to view
the previous window. Most commands work like <I>command</I>
<I>message_number</I>, for example, <TT>
<FONT COLOR="#0000ff">delete 14</FONT></TT> or <TT>
<FONT COLOR="#0000ff">reply 7</FONT></TT>.
The message number is the left column with an <TT>
<FONT COLOR="#0000ff">N</FONT></TT> next to it (for a
<TT>
<FONT COLOR="#0000ff">N</FONT></TT>ew message).
<P>
For the state of the art in terminal-based mail readers (also called
mail <I>clients</I>), try
<TT>
<FONT COLOR="#0000ff">mutt</FONT></TT> and <TT>
<FONT COLOR="#0000ff">pine</FONT></TT>. <FONT COLOR="#ffa500">[<TT>
<FONT COLOR="#0000ff">pine</FONT></TT>'s license is not Free.]</FONT>
<P>
There are also some graphical mail readers in various stages of
development. At the time I am writing this, I have been using
<TT>
<FONT COLOR="#0000ff">balsa</FONT></TT> for a few months, which was the best mail reader
I could find.
<P>
<H1><A NAME="SECTION001320000000000000000">
10.2 The SMTP Protocol -- Sending Mail Raw to Port <TT>
<FONT COLOR="#0000ff">25</FONT></TT></A>
</H1>
<P>
<A NAME="sec:sendamail"></A>
<P>
To send mail, you need not use a mail client at all. The mail
client just follows <I>SMTP</I> (Simple Mail Transfer Protocol), which you can type in from the keyboard.
<P>
For example, you can send mail by <TT>
<FONT COLOR="#0000ff">telnet</FONT></TT><I>ing</I> to
<I>port 25</I> of a machine that has an
<I>MTA</I> (Mail Transfer Agent--also called the <I>mailer daemon</I>
or <I>mail server</I>)
running. The word <I>daemon</I> denotes programs that
run silently without user intervention.
<P>
<A NAME="sec:spam"></A>This is, in fact, how so-called <I>anonymous mail</I> or
<I>spam mail</I> <FONT COLOR="#ffa500">[<I>Spam</I> is a term used to indicate
unsolicited email--that is, junk mail that is posted in bulk to
large numbers of arbitrary email addresses. Sending spam is considered
unethical Internet practice.]</FONT> is sent on the Internet. A mailer
daemon runs in most small institutions in the world and has the
simple task of receiving mail requests and relaying them on to other
mail servers. Try this, for example (obviously substituting
<TT>
<FONT COLOR="#0000ff">mail.cranzgot.co.za</FONT></TT> for the name of a mail server that you
normally use):
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red size="-1">
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>10</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>15</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-2"><code>20</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue size="-1">
<code>[root@cericon]# <font color="navy"><B>telnet mail.cranzgot.co.za 25</B></font></code><br>
<code>Trying 192.168.2.1...</code><br>
<code>Connected to 192.168.2.1.</code><br>
<code>Escape character is '^]'.</code><br>
<code>220 onion.cranzgot.co.za ESMTP Sendmail 8.9.3/8.9.3; Wed, 2 Feb 2000 14:54:47 +0200</code><br>
<code><font color="navy"><B>HELO cericon.cranzgot.co.za</B></font></code><br>
<code>250 onion.cranzgot.co.za Hello cericon.ctn.cranzgot.co.za [192.168.3.9], pleased to meet yo</code><br>
<code><font color="navy"><B>MAIL FROM:psheer@cranzgot.co.za</B></font></code><br>
<code>250 psheer@cranzgot.co.za... Sender ok</code><br>
<code><font color="navy"><B>RCPT TO:mands@inetafrica.com</B></font></code><br>
<code>250 mands@inetafrica.com... Recipient ok</code><br>
<code><font color="navy"><B>DATA</B></font></code><br>
<code>354 Enter mail, end with "." on a line by itself</code><br>
<code><font color="navy"><B>Subject: just to say hi</B></font></code><br>
<code> </code><br>
<code><font color="navy"><B>hi there</B></font></code><br>
<code><font color="navy"><B>heres a short message</B></font></code><br>
<code> </code><br>
<code><font color="navy"><B>.</B></font></code><br>
<code>250 OAA04620 Message accepted for delivery</code><br>
<code><font color="navy"><B>QUIT</B></font></code><br>
<code>221 onion.cranzgot.co.za closing connection</code><br>
<code>Connection closed by foreign host.</code><br>
<code>[root@cericon]# </code><br>
</FONT></TD></TR></TABLE><P>
<P>
The above causes the message ``<TT>
<FONT COLOR="#0000ff">hi there heres a short
message</FONT></TT>'' to be delivered to <TT>
<FONT COLOR="#0000ff">mands@inetafrica.com</FONT></TT> (the
<TT>
<FONT COLOR="#0000ff">R</FONT></TT><I>e</I><TT>
<FONT COLOR="#0000ff">C</FONT></TT><I>i</I><TT>
<FONT COLOR="#0000ff">P</FONT></TT><I>ien</I><TT>
<FONT COLOR="#0000ff">T</FONT></TT>).
Of course, I can enter any address that I like as the sender, and it
can be difficult to determine who sent the message. In this
example, the <TT>
<FONT COLOR="#0000ff">Subject:</FONT></TT> is the only header field, although
I needn't have supplied a header at all.
<P>
Now, you may have tried this and gotten a rude error message. This
might be because the MTA is configured <I>not</I> to relay mail
except from specific trusted machines--say, only those
machines within that organization. In this way anonymous email is prevented.
<P>
On the other hand, if you are connecting to the user's very own mail
server, it has to necessarily receive the mail, regardless of who sent it. Hence, the above is a
useful way to supply a bogus <TT>
<FONT COLOR="#0000ff">FROM</FONT></TT> address and thereby
send mail almost anonymously. By ``almost'' I mean that the mail
server would still have logged the machine from which you
connected and the time of connection--there is no perfect anonymity
for properly configured mail servers.
<P>
The above technique is often the only way to properly test a mail
server, and should be practiced for later.
<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html1916"
HREF="node14.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
<A NAME="tex2html1912"
HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
<A NAME="tex2html1906"
HREF="node12.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
<A NAME="tex2html1914"
HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html1917"
HREF="node14.html">11. User Accounts and</A>
<B> Up:</B> <A NAME="tex2html1913"
HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html1907"
HREF="node12.html">9. Processes, Environment Variables</A>
  <B> <A NAME="tex2html1915"
HREF="node1.html">Contents</A></B>
<!--End of Navigation Panel-->
</BODY>
</HTML>
|