SourceForge VA Linux Systems
Copyright © 2000 Paul Sheer - Click here for copying permissions       Source by FTP

next up previous contents index
Next: User accounts and ownerships Up: Rute Users Tutorial and Previous: Processes and environment variables   Contents   Index

Subsections

Mail

Add comments here 
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 will show you how mail was first intended to be used on a multi-user 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. Although a mail message will usually 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, such as: jack@kangeroo.co.au. This means that jack has a user account on a computer called kangeroo.co.au. The text after the @ is always the name of the machine. Todays Internet does not obey this exactly, but there is always a machine that jack does have an account on where mail is eventually sent.
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 mail box file. Where <username> is your login name. You then run some program which 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 maynard@iafrica.com  Mon Jun  1 21:20:21 1998
Return-Path: <maynard@iafrica.com>
Received: from lava.obsidian.co.za (root@lava.obsidian.co.za [192.168.2.254])
        by ra.obsidian.co.za (8.8.7/8.8.7) with ESMTP id VAA11942
        for <psheer@cranzgots.co.za>; Mon, 1 Jun 1998 21:20:20 +0200
Received: from mail450.icon.co.za (mail450.icon.co.za [196.26.208.3])
        by lava.obsidian.co.za (8.8.5/8.8.5) with ESMTP id VAA19357
        for <psheer@cranzgots.co.za>; Mon, 1 Jun 1998 21:17:06 +0200
Received: from smtp02.iafrica.com (smtp02.iafrica.com [196.7.0.140])
        by mail450.icon.co.za (8.8.8/8.8.8) with SMTP id VAA02315
        for <psheer@cranzgots.co.za>; Mon, 1 Jun 1998 21:24:21 +0200 (GMT)
Received: from default [196.31.19.216] (fullmoon)
        by smtp02.iafrica.com with smtp (Exim 1.73 #1)
        id 0ygTDL-00041u-00; Mon, 1 Jun 1998 13:57:20 +0200
Message-ID: <357296DF.60A3@iafrica.com>
Date: Mon, 01 Jun 1998 13:56:15 +0200
From: a person <maynard@iafrica.com>
Reply-To: maynard@iafrica.com
Organization: private
X-Mailer: Mozilla 3.01 (Win95; I)
MIME-Version: 1.0
To: paul sheer <psheer@cranzgots.co.za>
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 it to your mail box, who sent the message, where replies should go to, the subject of the mail, and various other 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. From's 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 de facto standard.

Sending and reading mail

The simplest way to send mail is to use the mail command. Type mail -s "hello there" <username>. mail will then wait for you to type out your message. When you are finished, enter a . on its own on a single line. The username 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 local machine, localhost, is implied).
You can use mail to view your mailbox. This is a primitive utility in comparison to modern graphical mail readers but is probably the only mail reader that can handle arbitrary 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, eg delete 14 or reply 7 etc. The message number is the left column with an N next to it for new mail, etc.
For the state of the art in terminal based mail readers, try mutt and pine.
There are also some graphical mail readers in various stages of development. At the time I am writing this, I have been using TkRat for a few months, which was the best mail reader I could find.

The SMTP protocol -- sending mail raw to port 25

To send mail, it is actually not necessary to have 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) running.
This is in fact how, so-called, anonymous mail or spam mail13.1 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 onto other mail servers. Try this for example (obviously substituting mail.obsidian.co.za for the name of a mail server that you normally use):

 
 
 
 
5 
 
 
 
 
10 
 
 
 
 
15 
 
 
 
 
20 
 
 
[root@cericon tex]# telnet mail.obsidian.co.za 25
Trying 192.168.2.1...
Connected to 192.168.2.1.
Escape character is '^]'.
220 ra.obsidian.co.za ESMTP Sendmail 8.9.3/8.9.3; Wed, 2 Feb 2000 14:54:47 +0200
HELO cericon.obsidian.co.za
250 ra.obsidian.co.za Hello cericon.ctn.obsidian.co.za [192.168.3.9], pleased to meet you
MAIL FROM:psheer@cranzgots.co.za
250 psheer@cranzgots.co.za... Sender ok
RCPT TO:maynard@iafrica.com
250 maynard@iafrica.com... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
hi there
heres a short message

.
250 OAA04620 Message accepted for delivery
QUIT
221 ra.obsidian.co.za closing connection
Connection closed by foreign host.
[root@cericon tex]# 

The above causes the message ``hi there here is a short message'' to be delivered to maynard@iafrica.com (the ReCiPienT). Of course I can enter any address that I like as the sender, and it can be difficult to determine who sent the message.
Now, you may have tried this and got 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 organisation. In this way anonymous email is prevented.

next up previous contents index
Next: User accounts and ownerships Up: Rute Users Tutorial and Previous: Processes and environment variables   Contents   Index
Paul Sheer 2000-10-07