
			Internet Mail
			-------------

One of the the most popular of all computer applications is Electronic
Mail (Email). These days it forms an integral part of many peoples'
working lives and is as important to them and their work as the
telephone.

The biggest infrastructure for Email is provided by the Internet,
which as well as permitting Email communication between Internet
sites, allows gatewaying to other networks.  All sites that are
directly on the Internet communicate with each other via a common
language called the "Simple Mail Transport Protocol" (SMTP).  This
itself runs on top of the "Internet Protocol" (IP).  SMTP is another
TCP/IP service like the more familiar FTP and Telnet.  

When you create an Email message, you use a Mail User Agent (MUA).
These are the programs you - the User - use to create and read Email
messages.  Examples of popular MUAs are Elm, Pine and the X-windows
mailer, Messages.  Under Un*x, there are a _huge_ variety of MUAs.
It sometimes looks like anyone who knows how to program in C has
written a MUA at some stage.  I recommend that you adopt a popular MUA
simply because if something goes wrong, there is always extensive help
available from the Internet. 

The message you create with your MUA comprises two distinct parts, the
body of the message and the address.  The address is normally in a
form that says something meaningful about the location of the user,
e.g. j.haar@lazerjem.demon.co.uk.  The message is passed to the
system's Mail Transfer Agent (MTA). This program is responsible for
the transport of the Email message to its destination. Examples of
popular MTAs on the Linux platform are smail and sendmail. Your MTA
decides where the message is to go and sends it there, possibly
connecting to another MTA on a remote host in the process.  The
message is appended to a file which can then be accessed by the
recipient's MUA.  Under Linux, the message would be appended to the
file /usr/spool/mail/<usercode>. For example, my usercode is jason, so
mail for me appears in the file /usr/spool/mail/jason.

So, how *does* the MTA know what to do with your message? Given that a
computer identifies an Internet site by a *number* - its IP address
e.g.  158.152.26.235 - how does a MTA in New Zealand know what it
means when when you send an Email message to
"j.haar@lazerjem.demon.co.uk"?  SMTP would be very limited if it
wasn't for the existence of something that allows systems to work out
what IP address corresponds to what name. This role can be provided by
a host table (see /etc/hosts) but this is normally restricted to LAN
hosts only. For a network as large as the Internet, a host table is
impractical and a distributed database is available instead.  This is
the Domain Name Service (DNS).

The DNS is a clever beast. Besides containing records mapping
hostnames to IP addresses, it contains other information too including
the MX records.  These are used by MTAs in the decision process of
what to do with an Email address. MX records allows a site to tell the
rest of the Internet how Email to that site should be handled. The
site may decide that all incoming Email should be sent to a central
mailhost instead of to the individual hosts (or not). The site may
also decide to create secondary MX records which tell MTAs where to
send messages if the primary mail site is down (it is good practice
for sites to have at least two MX records). Although the DNS is a
distributed database, each site is in charge of its own information.
If a new host is added to the DNS at one site, within about a day
every site on the Internet will automatically know about it.

To demonstrate all this, let's use a real-life example. Suppose I 
want to send an Email message to Kaylene Murdoch at Oxford University.

1) 	I create the Email message to k.murdoch1@ph.ox.ac.uk using my
        favourite MUA, Messages.

2)	The MUA passes off the message to my Linux system's MTA, 
	sendmail-8.6.5.

3)	The MTA asks the DNS for information about ph.ox.ac.uk, and
	is told that any Email messages to that address should actually be
	send to mail.physics.ox.ac.uk. The DNS is then asked what the 
	IP address is for the string "mail.physics.ox.ac.uk" and returns 
	the value 111.222.111.222. 

4)	My Linux system then starts an SMTP connection to 111.222.111.222, 
	transmits the message, and then closes down the connection.

5)	mail.physics.ox.ac.uk then goes through a similar series of actions 
	to make the final delivery to to the machine oxds02.astro.ox.ac.uk, 
        whereupon Kaylene reads my message with her favorite MUA, Pine.

Anyone with access to the Internet should be using the DNS. If you
access the Internet via dial-up rather than Ethernet, IP connectivity
is possible via SLIP/PPP.  With  PPP/SLIP access you have two options.

1)	Configure your MTA to use the DNS, so that every message you send 
	goes to its destination via MX record lookups

2)	Configure your MTA to simply forward all non-local mail you send to 
	an Ethernet-connected Internet MTA. In this case that MTA will do
        all the MX lookups and the final delivery. This will result in
	shorter phone-calls, as
	all the waiting for connections to hosts on the other side of the 
	world will be done by the fully Internet-connected mail server. You 
	had better check first with your Internet provider to see if they 
	mind. 

Needless to say, no matter which option you choose, you should still 
configure your Linux box to use the DNS. Don't forget, you still want the 
DNS for non-Email events like telnet and ftp.

Configuring Linux to use the DNS is very easy. It involves editing two files:

1)	edit /etc/resolv.conf

#-------- BEGIN FILE ---------
#/etc/resolv.conf

#Define what domain your host is a member of. As an example, my Linux box 
#hangs off the "demon.co.uk" network (my fully-qualified domain name is
# "lazerjem.demon.co.uk"). PLEASE EDIT THIS!!!!

domain demon.co.uk

#Now tell your system where it can send DNS queries to. You can have up to
# three (?) Domain Name Servers as a list here. If the first one isn't 
# available, the second one will be asked, etc.
# Chose name servers that are close by to ensure speedy response

nameserver 158.152.1.65

#-------- END FILE ----------


2) edit /etc/host.conf

#------- BEGIN FILE ---------

# The "order" keyword tells Linux the order in which it should search in 
# host name lookups. The general case is to search /etc/hosts first, and 
# if the host isn't in there, as DNS (called bind for this file)

order hosts bind

#-------- END FILE ----------


That's it! Now any IP application should be able to use the DNS.

Now that this introduction to Internet Mail is over, let's move onto the 
messy stuff - actually configuring the sendmail-8.6 MTA.




APPENDIX: FURTHER REFERENCES
----------------------------

The primary references for TCP/IP services such as SMTP are the
"Requests For Comments" (RFCs).  These documents are available via
anonymous FTP from a variety of sites (use Archie), and cover ALL
Internet protocols. There are RFCs on Telnet, FTP, Usenet News, as
well as SMTP.


RFC 822	 	D. Crocker, "Standard for the format of ARPA Internet text 
		messages" 08/13/1982

RFC 1425	J. Klensin, N. Freed, M. Rose, E. Stefferud, D. Crocker, "SMTP
           	Service Extensions", 02/10/1993. (Pages=10) (Format=.txt)

RFC 1522	K. Moore, "MIME (Multipurpose Internet Mail Extensions) Part 
		Two: Message Header Extensions for Non-ASCII Text", 09/23/1993.	

RFC 1521	N. Borenstein, N. Freed, "MIME  (Multipurpose Internet Mail
           	Extensions) Part One:  Mechanisms for Specifying and 
		Describing the Format of Internet Message Bodies", 09/23/1993.



RFC 819       	Z. Su, J. Postel, "Domain naming convention for Internet 
		user  applications", 08/01/1982



















