the email address. Mail exchangers: These are the hosts that receive and send e-mail. The domain name assigned to each mail exchanger may be a DNS database or a logical name. This chapter has details on the user agent, mail transfer agents, and the mail delivery. SMTP is used for explaining the concepts. Perl programming language is used to show a programming example on implementing mail communication. Standard SMTP libraries are available in most of the high level programming languages. These libraries make client and server programming for mail communi- cation easy. This chapter also uses an SMTP library in Perl programming language to code the example program for mail communication. 29.2 Mail Delivery Process The SMTP is the TCP/IP protocol that defines e-mail services on the Internet. The client-server is used for exchange of mail messages. Commands are sent from the client to the server while responses are sent from the server to the client. Both the commands and the responses carry messages across client and server (see Figure 29.1). A keyword followed by zero or more arguments makes up a command. There are 14 commands defined by SMTP. There are three phases of mail transfer: 1. Connection establishment 2. Message transfer 3. Connection termination The SMTP server starts the connection phase after the client has established a TCP connection to the well-known port 25. Exchange of a single message takes Mail Communication Commands Client Server Responses Figure 29.1 Client-server model of mail transfer. client server server access access server client Figure 29.2 Mail delivery process. place between the sender and one or more recipients after the establishment of a connection between the SMTP client and server. The connection between the SMTP client and server is terminated by the client after the successful transfer of the message between them. The transfer of mails from the sender to the receiver involves the following stages (see Figure 29.2): a. Stage 1: The mail is transferred from the user agent that us