What Is Mail?

Team-Fly    

Solaris™ Operating Environment Boot Camp
By David Rhodes, Dominic Butler
Table of Contents
Chapter 20.  Setting Up The Mail System


We can think of mail as being the electronic version of the normal postal servicein fact, let's use this comparison to see how it works in more detail. If we look at the following steps, we'll see they are the tasks that are carried out whenever we send a "manual" letter to someone:

  1. Write the letter and sign it.

  2. Address it to the correct person.

  3. Put it in an envelope.

  4. Post it.

  5. Send it to the post office in the correct area.

  6. Deliver it to the correct recipient.

All these tasks are also performed when sending email, although we aren't always aware of this because the task may be carried out automatically by the system. To find out how it achieves this, let's work through the above steps, using the "manual" letter shown in Figure 20.1 as an example.

Figure 20.1. The "manual" letter.

graphics/20fig01.gif

The electronic version of this letter will actually be split into a number of different components by the mail system. We'll use the labels shown in Figure 20.2 to describe each of these.

Figure 20.2. The different components of the letter.

graphics/20fig02.gif

1 Write the Letter

The first task is to create the "Body" of the message. This can be done in a variety of ways: Text may be entered into a GUI application such as mailtool or dtmail, typed into one of the command line variants such as mail or mailx, or perhaps fed in from an input file. Whichever one of these is used, they are all examples of a Mail User Agent (MUA). This forms the interface between the user and the mail system.

For our examples here, we'll continue with our practice of using non-GUI commands; therefore, we'll use mail to enter any details. Let's now start to create the message by passing the "To Address" and the "Subject" fields on the mail command line:

 hydrogen# mail -s "Re: Design Timetable" jim.davies@destination.com 

Mail is now waiting for us to enter the message. It will read our text from standard input until either a single dot (on a line by itself) or an EOF (End-of-file) marker is seen.

 Hi Jim, Thanks for the letter earlier--I'll work on the design timetable and get it to you asap. Regards, Harry . hydrogen# 

Here we've entered the text and the correct end-of-message marker, then received our prompt back. This means that the message has been sent, as far as we're concerned. What that means in reality is that the mail system will carry on with the rest of its processing and will only need to contact us if it has any delivery problems with the message.

2 Address It

We can see that in step 1 we included the address of the recipient in the mail command. This looks suspiciously similar to the syntax that we used to describe domain names earlier in Chapter 16, "Configuring DNS." There, we referred to machines such as "somemachine.somedomain.com." Domain names and mail addresses are tightly related. In fact, the mail address is simply an extension of the domain name and allows us to specify the name of a user along with the name of the machine (or domain) that the user belongs to (the two being separated by an "@" character). This is known as their "absolute mail address."

For example, the address of our recipient is jim.davies@destination.com. This means that the letter will be sent to the machine that handles mail for the domain "destination.com." Once it arrives there, the local mail system will deliver it locally to the user known as "jim.davies." (Note that, in this example, the mail is sent to the domain rather than to a specific machine.)

3/4 Put It in an Envelope/Post It

Now that we know where to send the message, we can "post it" by passing it on to a piece of software known as a Mail Transfer Agent (MTA). This obtains the addresses of both the sender and any recipients from the MUA. From there the MTA generates the envelope for the messageours will look like the one shown here:

 Mail From: harry.king@some-corp.com Rcpt To: jim.davies@destination.com 

The envelope now contains the address information, which is formatted exactly as the MTA needs it (or, more correctly, as the mail protocol specifies). It will only contain one "Mail From" field, but may have a number of "Rcpt To" ones, depending on whether we were sending the message to multiple people or not. When it's been created, the envelope is used by the MTA to correctly route the mail to the specified recipients and also to send any errors back to the sender if any delivery problems occur.

The Header

Besides creating the envelope, the MTA also generates a header that is prepended to the body of the message. This is formatted as a series of "keyword: value" entries, and is the "readable" version of the envelope. The header also includes other information, such as time stamps, message IDs, reply addresses, and so forth. It will be updated by each MTA that it passes between. By the time the message arrives at its intended user, the header may contain a whole series of information that shows all the stages and timings taken to get to its destination. A simple example of a header is shown below:

 Reply-To: harry.king@some-corp.com Date: Mon, 22 Oct 2001 11:07:59 GMT To: jim.davies@destination.com From: harry.king@some-corp.com Subject: Re Design Timetable 
Delivery Checks

The MTA takes responsibility for any mail passed to it, which means that messages should either be delivered or returned back to the sender with an error messageno mail should ever be lost. Many MTAs are configured to perform a variety of different checks before they accept the message. Examples of these are listed below:

  • Check that the domain of the sender and the recipient are valid

  • Check the number of recipients for the mail (to guard against junk mail)

  • Check that the user sending the mail is a local user

If all the delivery checks are successful, the MTA will take ownership of the mail, allocate a message ID number for it, and place it on the mail queue ready for sending.

5 Send It to the Correct Area

If the message is not for a local user, the MTA must forward it to the machine that acts as the MTA's mail server. To do this, the MTA needs to determine which machine to forward to by performing a DNS lookup (we'll look at this in more detail in the section "DNS and Mail" on page 491). When it has obtained this information, the local MTA will open a connection to the remote one and try to pass the mail on to it. The remote MTA will also probably perform some delivery checks, similar to those mentioned earlier, before deciding whether to accept the mail or reject it.

6 Local Delivery

Finally, the mail has arrived on the correct system and has been accepted by the receiving MTA. From here, it is passed on to a program known as the Mail Delivery Agent (MDA). On Solaris, this is a program named /usr/lib/mail.local. It is responsible for delivering the mail to the user's mailbox. It does this by simply taking the new message and appending it onto the user's existing mail file. Once the user's mailbox has been updated, the user will be able to access and read mail.

Mail Files

So where is all the mail stored? On Solaris, each user is allocated a mailbox. This is actually one big ASCII text file. If we take a look in /var/mail, we should see a number of files already there. There will normally be one for each user. However, there isn't any cause for concern if any are missingit simply means the user hasn't received any mail yet. When the user does receive mail, a mailbox will automatically be created.

For example, let's assume that John Green has received some test mail. It has been received by the MTA and delivered into his mailbox:

 hydrogen# cd /var/mail hydrogen# ls -l jgreen -rw-rw----   1 jgreen    mail     660 Dec 19 19:54 jgreen hydrogen# 

We can see that each file takes the name of the user's login, and that all users have ownership of their own mail files. Let's take a look to see what it contains:

 hydrogen# cat jgreen From root Wed Dec 26 19:58:57 2001 Received: (from root@localhost)    by xenon.solarisbootcamp.com (8.9.1b+Sun/8.9.1) id TAA00564    for jgreen; Wed, 26 Dec 2001 19:58:56 GMT Date: Wed, 26 Dec 2001 19:58:56 GMT From: Super-User <root> Message-Id: <200112261958.TAA00564@xenon.solarisbootcamp.com> Content-Type: text Content-Length: 17 First test mail From root Wed Dec 26 19:59:57 2001 Received: (from root@localhost)    by xenon.solarisbootcamp.com (8.9.1b+Sun/8.9.1) id TAA00565    for jgreen; Wed, 26 Dec 2001 19:59:56 GMT Date: Wed, 26 Dec 2001 19:59:56 GMT From: Super-User <root> Message-Id: <200112261958.TAA00565@xenon.solarisbootcamp.com> Content-Type: text Content-Length: 18 Second test mail hydrogen# 

This shows that each message begins with the header that we described earlier. The header is separated from the body of the message by a single blank line. After that we can see the body of the message, and lastly another blank line that is used to separate each message. This example shows that jgreen currently has two mail messages waiting for him.


    Team-Fly    
    Top
     



    Solaris Operating Environment Boot Camp
    Solaris Operating Environment Boot Camp
    ISBN: 0130342874
    EAN: 2147483647
    Year: 2002
    Pages: 301

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net