How the sendmail Program Works

The following sections describe how the sendmail program works.

When a sender wants to send a message, the program issues a request to sendmail. The sendmail program then goes through the steps listed below, which are described in detail in the following sections.

1.
Arguments are processed and the address is then parsed.

2.
The message is collected.

3.
The message is delivered.

4.
If instructions are received from the mailer, the message is queued for retransmission.

5.
If errors occur during processing, the message is returned to the sender.

Argument Processing and Address Parsing

If sendmail is called by means of the argument vector or is connected to through a pipe, the arguments are first scanned and option specifications are processed. Recipient names are then collected, either from the command line or from the SMTP command, and a list of recipients is created. Aliases, including mailing lists, are expanded at this step. As much validation as possible of the remote recipient is done at this step: Syntax is checked and local recipients are verified, but detailed checking of host names is deferred until delivery. Forwarding is also performed as the local recipients are verified.

The sendmail program appends each name to the recipient list after parsing. When a name is aliased or forwarded, the old name is retained in the list and a flag is then set to tell the delivery phase to ignore this recipient. This list is kept free from duplicates, thus preventing alias loops and duplicate messages from being delivered to the same recipient, as might occur when a person is in two alias lists.

NOTE

Users may receive duplicate copies of the same message when alias lists contain e-mail addresses for the same person but with different syntaxes. The sendmail program cannot always identify the e-mail addresses as duplicates of one another.


Message Collection

The sendmail program then collects the message, which has a header at the beginning. The message body does not need to be formatted in any special way except that it must be composed of lines of text. (In other words, binary data is not allowed.) The header is stored in memory, and then the body of the message is saved in a temporary file.

To simplify the program interface, the message is collected even if no names were valid. The message subsequently is returned with an error.

Message Delivery

For each unique mailer and host in the recipient list, sendmail calls the appropriate mailer. Each mailer invocation sends the message to all users receiving it on one host. Mailers that accept only one recipient at a time are handled properly.

The message is sent to the mailer through one of the same three interfaces used to submit a message to sendmail. Each copy of the message has a customized header added to the beginning of the message. The mailer status code is caught and checked, and a suitable error message is given if appropriate. The exit code must conform to a system standard or the generic message Service unavailable is displayed.

Retransmission Queuing

When the mailer returns a status indicating that it might be able to handle the mail later, sendmail queues the mail and tries again later.

Return to Sender

When errors occur during processing, sendmail returns the message to the sender for retransmission. The letter can be mailed back (when the mail comes from a different site) or written to the dead.letter file in the sender's home directory.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.103.206