Purchase | Copyright © 2002 Paul Sheer. Click here for copying permissions. | Home |
Electronic Mail, or email, 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.
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 subject 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: [email protected]. This means that bruce has a user account on a computer called kangeroo.co.au, which often means that he can log in as bruce on that machine. The text after the @ is always the name of the machine. Today's Internet does not obey this exactly, but there is always a machine that bruce does have an account on where mail is eventually sent. [That machine is also usually a UNIX machine.]
Sometimes email addresses are written in a more user-friendly form like Bruce Wallaby <[email protected]> or [email protected] (Bruce Wallaby). In this case, the surrounding characters are purely cosmetic; only [email protected] is ever used.
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 /var/spool/mail/<username> called the mail file or mailbox file; <username> 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.
An actual addition to your mail file might look like this:
5 10 15 20 25 30 35 |
From [email protected] Mon Jun 1 21:20:21 1998 Return-Path: <[email protected]> Received: from pizza.cranzgot.co.za ([email protected] [192.168.2.254]) by onion.cranzgot.co.za (8.8.7/8.8.7) with ESMTP id VAA11942 for <[email protected]>; Mon, 1 Jun 1998 21:20:20 +0200 Received: from mail450.icon.co.za (mail450.icon.co.za [196.26.208.3]) by pizza.cranzgot.co.za (8.8.5/8.8.5) with ESMTP id VAA19357 for <[email protected]>; Mon, 1 Jun 1998 21:17:06 +0200 Received: from smtp02.inetafrica.com (smtp02.inetafrica.com [196.7.0.140]) by mail450.icon.co.za (8.8.8/8.8.8) with SMTP id VAA02315 for <[email protected]>; Mon, 1 Jun 1998 21:24:21 +0200 (GMT) Received: from default [196.31.19.216] (fullmoon) by smtp02.inetafrica.com with smtp (Exim 1.73 #1) id 0ygTDL-00041u-00; Mon, 1 Jun 1998 13:57:20 +0200 Message-ID: <[email protected]> Date: Mon, 01 Jun 1998 13:56:15 +0200 From: a person <[email protected]> Reply-To: [email protected] Organization: private X-Mailer: Mozilla 3.01 (Win95; I) MIME-Version: 1.0 To: paul sheer <[email protected]> Subject: hello Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Status: RO X-Status: A hey paul its me how r u doing i am well what u been upot hows life hope your well amanda |
Each mail message begins with a From at the beginning of a line, followed by a space. Then comes the mail header, 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 mail header fields. Above, the header is longer than the mail messages. Examine the header carefully.
The header ends with the first blank line. The message itself (or body) starts right after. The next header in the file will once again start with a From. Froms on the beginning of a line never exist within the body. If they do, the mailbox is considered to be corrupt.
Some mail readers store their messages in a different format. However the above format (called the mbox format) is the most common for UNIX. Of interest is a format called Maildir, which is one format that does not store mail messages in a single contiguous file. Instead, Maildir 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 Maildir within the user's home directory.
The simplest way to send mail is to use the mail command. Type mail -s "hello there" <username>. The mail program will then wait for you to type out your message. When you are finished, enter a . 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 root with mail -s "Hello there" root or mail -s "Hello there" root@localhost (if the @ is not present, then the local machine, localhost, is implied). Sending files over email is discussed in Section 12.6.
You can use mail 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 mail is the only way to delete messages from it. To view your mailbox, type mail, and then z to read your next window of messages, and z- to view the previous window. Most commands work like command message_number, for example, delete 14 or reply 7. The message number is the left column with an N next to it (for a New message).
For the state of the art in terminal-based mail readers (also called mail clients), try mutt and pine. [ pine's license is not Free.]
There are also some graphical mail readers in various stages of development. At the time I am writing this, I have been using balsa for a few months, which was the best mail reader I could find.
To send mail, you need not use a mail client at all. The mail client just follows SMTP (Simple Mail Transfer Protocol), which you can type in from the keyboard.
For example, you can send mail by telneting to port 25 of a machine that has an MTA (Mail Transfer Agent--also called the mailer daemon or mail server) running. The word daemon denotes programs that run silently without user intervention.
This is, in fact, how so-called anonymous mail or spam mail [Spam 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.] 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 mail.cranzgot.co.za for the name of a mail server that you normally use):
5 10 15 20 |
[root@cericon]# telnet mail.cranzgot.co.za 25 Trying 192.168.2.1... Connected to 192.168.2.1. Escape character is '^]'. 220 onion.cranzgot.co.za ESMTP Sendmail 8.9.3/8.9.3; Wed, 2 Feb 2000 14:54:47 +0200 HELO cericon.cranzgot.co.za 250 onion.cranzgot.co.za Hello cericon.ctn.cranzgot.co.za [192.168.3.9], pleased to meet yo MAIL FROM:[email protected] 250 [email protected]... Sender ok RCPT TO:[email protected] 250 [email protected]... Recipient ok DATA 354 Enter mail, end with "." on a line by itself Subject: just to say hi hi there heres a short message . 250 OAA04620 Message accepted for delivery QUIT 221 onion.cranzgot.co.za closing connection Connection closed by foreign host. [root@cericon]# |
The above causes the message `` hi there heres a short message'' to be delivered to [email protected] (the Re Ci Pien T). 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 Subject: is the only header field, although I needn't have supplied a header at all.
Now, you may have tried this and gotten a rude error message. This might be because the MTA is configured not to relay mail except from specific trusted machines--say, only those machines within that organization. In this way anonymous email is prevented.
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 FROM 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.
The above technique is often the only way to properly test a mail server, and should be practiced for later.