Приглашаем посетить
Гумилев (gumilev.lit-info.ru)

13.1 An introduction to email and mail agents

Table of Contents

Previous Next

13.1 An introduction to email and mail agents

13.1.1 Set up your mail agents

The ability to send an electronic message (email) to customers, friends, or groups of people anywhere has become a daily necessity for a computer system. Many systems can also inform the user of any incoming mail at the time when he or she logs in to the system. For example, the user will see a message such as "You have mail" in UNIX (or LINUX) systems, or be greeted by a voice message by some ISPs. In Microsoft Windows systems, a mail user agent such as Outlook Express can even allow the user to access different accounts from different ISPs. In this chapter, we are going to discuss email systems and how to program them on the Web. Basic browser emailing to server mail with ASP, PHP, and Perl is also discussed. Information on the Simple Mail Transfer Protocol (SMTP), Post Office Protocol (POP3), and Multipurpose Internet Mail Extension (MIME) is provided for practical purposes. Examples are given to show how to use them on the Web. Before you can gain access and control the email system, some basic knowledge of email messages and their agents is essential.

An email system has two fundamental components: the mail user agent (e.g., Outlook Express) and the mail transport agent (e.g., sendmail and smail). The user agent is the interface to the mail package that you use to write and read mails. The transport agent handles the actual processes of sending and receiving mails and is usually hidden from front end users. To install an email system and its associated agents from scratch is normally the job of the network administrator and your ISP. However, several simple steps to configure your email system can enhance the understanding of how email systems function on the Web.

One of the important tasks for mail delivery is to handle addresses for the sender and the recipient. For the Transmission Control Protocol/Internet Protocol (TCP/IP), or simply Internet convention, a typical email address may look like this: JohnSmith@pwt-ex.com. That is, user JohnSmith at domain name pwt-ex.com. From the sender to the recipient, the transport agent must establish a connection from the sender's domain (or machine) to a mail machine somewhere along the route to the destination and to deliver the mail. For TCP/IP networks, the SMTP is often used to establish the process of sending mails, while the POP3 is usually used for receiving mails. If a user signs up to an ISP, the ISP should provide the user with two machine names (SMTP and POP3 servers) together with other information so that the user can commission the mail agents to send or get emails. In the case of home users, for example, the typical information needed to set up the mail agents and the accounts are:

  • Service provider's telephone number

  • User name or account name

  • Password

  • Email address (e.g., JohnSmith@pwt-ex.com)

  • SMTP server name (e.g., smtpmail.pwt-ex.com)

  • POP3 server name (e.g., popmail.pwt-ex.com)

The first three pieces of information are used to establish the connection to the ISP using a telephone line. If you have a permanent connection, a telephone number is not needed. The user name and password will then be used again together with the remaining information to set up the mail user agent so that you can read, write, and deliver emails.

The SMTP and POP3 servers could be the same machine. As an example, let's consider how to set up the email user agent Outlook Express. First, you activate Outlook Express and go to Tools, Accounts, press Add, and select Mail to launch the "Internet Connection Wizard." After the creation of a name for your email account, you need to fill in your email address (Fig. 13.1). When you press the Next button, the Wizard will ask you for the email server names (Fig. 13.2).

Figure 13.1. Email address

graphics/13fig01.gif


Figure 13.2. Email servers

graphics/13fig02.gif


Another Next button takes you to the final dialog box. In this dialog box, you need to fill in your user name and password in order to gain access to your own email account (Fig. 13.3). Outlook Express is now ready to send and receive emails. Your email account will appear in Outlook Express's "Internet Account," window (Fig. 13.4).

Figure 13.3. User name and password

graphics/13fig03.gif


Figure 13.4. Email account

graphics/13fig04.gif


You follow a similar procedure to set up the mail agents on other systems. Depending on the ISP, sometimes you may also need the information called Domain Name System (DNS) to solve some naming conventions.

In order to simplify mail traffic on the Internet and to deliver email more effectively, your mail host normally uses Mail Exchanger to route all mails to you and other users to this machine. The use of a mail exchanger allows machines that are not connected to the Internet all the time to have mails received by a host (or service provider).

As an email user, you don't need to know much about the mail transport agents (sendmail, smail, etc.) and how they work. You need only to concentrate on the mail user agent, i.e., reads, writes, and sends emails. As a Web programmer, knowledge of how to control email and in particular program the user agent is needed. Before you can control the user agent effectively, you need to understand the basic structure and controllable components of an email.

13.1.2 Basic components of an email

An email message consists of a body and a header. The body part is usually text based and is the content of the message. The header is a chunk of information at the beginning of the message that contains information such as the sender, recipient, date, and subject. A blank line separates the header and the body parts. Many emails also include data at the end, called a signature, to provide further information on the sender.

The following is a typical header from a mail agent:



Listing: ex13-01.txt - Basic Components Of An Email

 1: X-Envelope-To: JohnSmith@pwt-ex.com
 2: Received: from sand2.global.net.uk ([195.147.246.100])
 3:    by mx2.global.net.uk with esmtp (Exim 3.03 #41)
 4:    id 143xOF-00071a00
 5:    for JohnSmith@pwt-ex.com; Thu, 04 Dec 2003 09:30:59 +0000
 6: Received:from pa4s11a08.client.global.net.uk([195.147.91.165]helo=JohnSmith)
 7:    by sand2.global.net.uk with smtp (Exim 3.16 #1)
 8:    id 143xOZ-0002EV00
 9:    for JohnSmith@pwt-ex.com; Thu, 04 Dec 2003 09:31:19 +0000
10: Message-ID: <000201c06031$4e6cefc0$a55b93c3@JohnSmith>
11: From: "JohnSmith" <JohnSmith@pwt-ex.com>
12: To: <JohnSmith@pwt-ex.com>
13: Subject: Hello
14: Cc: John@pwt-ex.com
15: Date: Thu, 4 Dec 2003 09:33:40 0000
16: MIME-Version: 1.0
17: Content-Type: multipart/alternative;
18:    boundary="----=_NextPart_000_0005_01C06030.C8E32540"
19: X-Priority: 3
20: X-MSMail-Priority: Normal
21: X-Mailer: Microsoft Outlook Express 5.00.2314.1300
22: X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
23: X-Envelope-From: JohnSmith@pwt-ex.com

Line 1 is the Envelope containing the address of the recipient. The two Received fields (lines 29) are used to show which machines last relayed the email to you (or your machine). The Received field can have many different formats and aliases. Each intermediate machine will and can add a line to show the path of the email before reaching you. The Message-ID field (line 10) is a unique number used to identify your message. These are the system fields and will be handled by various email agents and systems.

The user input areas include the From field (line 11) that contains the identity and address of the sender. The To field (line 12) shows the recipient of the email. The Subject field (line 13) provides a description of the message. The Cc field (line 14) contains the identity addresses of any other users that should also have a copy of the message. Together with the email body, these are the controllable fields that we are going to use with our Web technologies.

The Date field (line 15) lists the date when the original email was sent. The remaining information (lines 1623) specifies the email document type and the identity of the mail agent.

Many mail agents have built-in extensions to include some functions such as multimedia, special international language sets, encryption, and many others. Let's begin with a discussion of email control with browsers.

    Table of Contents

    Previous Next