Home > Articles > Networking

  • Print
  • + Share This
This chapter is from the book

Mail Service Programs

Mail services are provided by a combination of programs that interact, as shown by the simplified diagram in Figure 3.

Figure 3 How Mail Programs Interact

Users send messages with programs—known as mail user agents (MUAs)—such as mailx, mailtool, or dtmail. See the manual pages for information about these programs.

The message is collected by the program that was used to generate it and is passed to the sendmail daemon or mail transport agent (MTA). The sendmail daemon parses (divides into identifiable segments) the addresses in the message, using information from the configuration file /etc/mail/sendmail.cf to determine network name syntax, aliasing, forwarding information, and network topology. Using this information, sendmail determines the route a message must take to get to a recipient.

The sendmail daemon passes the message to the appropriate mail hub, where it is handed off to a mail delivery agent. The /usr/lib/mail.local program—an example of a mail delivery agent—on the mail hub delivers the mail to the mailbox in the /var/mail/username file of the recipient of the message.

The user is notified that mail has arrived and retrieves it using an MUA such as /bin/mail, /bin/mailx, mailtool, dtmail, or a similar program.

Mail User Agents (MUAs)

The mail user agent is the program that acts as the interface between the user and the sendmail program. The MUAs for the Solaris Operating Environment are /usr/bin/mail, /usr/bin/mailx, $OPENWINHOME/bin/mailtool, and /usr/dt/bin/dtmail.

Mail Transport Agent (MTA)

The transport agent actually receives and deliveres messages. The transport agent for the Solaris Operating Environment is sendmail.

Open source sendmail is available at the http://www.sendmail.org Web site, which is maintained by the Sendmail Consortium. At the time of writing, the current version of sendmail is 8.11.3. Sun compiles sendmail version 8.9.3 and provides it as part of Solaris.

The transport agent performs the following functions.

  • Accepts messages from the mail user agent.

  • Understands destination addresses.

  • Hands off mail originating on the local system to the proper delivery agent.

  • Receives incoming mail from other MTAs and hands it off to delivery agents for delivery to local users.

If you want to use a more current version of sendmail than Sun provides, you can download it from http://www.sendmail.org. Two additional Web sites provide additional information about sendmail. A forum at http://www.sendmail.net disseminates information about and discuss sendmail. It has many useful articles and publishes news related to sendmail. http://www.sendmail.com sells a commercial version of sendmail. This version has nice graphical tools to help you customize sendmail.

The sendmail Configuration File (sendmail.cf)

A configuration file controls the way that sendmail performs its functions. The configuration file determines the choice of delivery agents, address-rewriting rules, and the format of the mail header. It also enables you to specify options that modify the functionality of different features or to turn the features on or off.

The sendmail program uses the information from the /etc/mail/sendmail.cf file to perform its functions. Each system has a default sendmail.cf file installed in the /etc/mail directory. You may not need to build a customized configuration file for your mail clients, but you do need to build them for your gateways and mail hubs.

The Solaris Operating Environment provides two default configuration files, which are also in the /etc/mail directory.

  • A configuration file named main.cf for the system (or systems) you designate as the mail hub or a gateway.

  • A configuration file named subsidiary.cf (a duplicate copy of the default sendmail.cf file).

Which configuration file you use on any individual system depends on the role the system plays in your mail service.

  • For mail clients, you do not need to do anything to set up or edit the default configuration file.

  • To set up a mailhost, a relay host, or a gateway, copy the /usr/lib/mail/cf/main-v7sun.mc file and rename it with a .mc (mail configuration) suffix. Next, edit the .mc file to set parameters needed for your mail configuration: gateway and mail hub. You must then "compile" the file, using the m4 macro processor. See "Generating the sendmail Configuration File" on page 53 for more information. Refer to Chapter 2, "Customizing sendmail Configuration Files" for information on editing configuration files.

The following list describes some configuration parameters you may want to change, depending on the requirements of your site.


You change these parameters in the .mc file that is used to generate the sendmail.cf file, not in the sendmail.cf file itself. The parameters are mentioned here so that you know what they look like in the resulting configuration file.

  • Time values.

    Specify how often sendmail runs the queue. The interval is typically set to between 15 minutes and 1 hour.

    Specify read timeouts.

    Specify how long a message remains in the queue before it is returned to the sender.

  • Delivery modes specify how quickly mail is to be delivered.

  • Load limiting prevents wasted time during loaded periods because it does not attempt to deliver large messages, messages to many recipients, or messages to sites that have been down for a long time.

  • Log level specifies what kinds of problems are logged.

  • File modes.

    setuid for sendmail.

    Temporary file modes.

    /etc/mail/aliases permissions.

The sendmail program receives a message from a program such as mailx, mailtool, or dtmail, edits the message header as required by the destination mailer, and calls appropriate delivery agents to make the delivery. If delivery cannot be made immediately, sendmail requeues the request and tries to hand off delivery to the proper delivery agent at regular intervals until delivery is successful or until a timeout value is reached.


The sendmail program never edits or changes the body of a message. Any changes that it makes to interpret e-mail addresses are made only in the header of the message.

Argument Processing and Address Parsing

When sendmail processes a message, it collects recipient names (either from the command line or from the SMTP protocol) and generates two files. One is an envelope that contains a list of recipients and information about delivery. The other file contains the header and the body of the message. The sendmail program ex_pands aliases, including mailing lists, and validates as much as possible the remote recipient; sendmail checks syntax and verifies local recipients. Detailed checking of host names is deferred until delivery. As local recipients are verified, messages are forwarded to them.

After parsing the recipient lists, sendmail appends each name to both the envelope and the header of the message. When a name is aliased or forwarded, it retains the old name in the list and sets a flag to tell the delivery phase to ignore this recipient. The lists are kept free from duplicates, preventing "alias loops" and duplicate messages delivered to the same recipient, which can occur if a recipient is in two different alias groups.


Users may receive duplicate copies of the same message when alias lists contain e-mail addresses for the same person (who is using different syntax). The sendmail program cannot always match the duplicate e-mail addresses.

Message Collection

The sendmail program then collects the message. The message has a header at the beginning. The header and the body of the message must be separated by a blank line. The only formatting requirement imposed on the message body is that its lines of text must be no greater than 1,024 bytes. The sendmail program stores the header in memory and stores the body of the message in a temporary file. To simplify the program interface, the message is collected even if no names are valid—in which case the message is returned with an error.


Until now, sendmail could not transmit binary data as part of mail messages. With the advent of the multimedia mailtool, users can now transmit binary data. It must, however, be encoded by a mail user agent. sendmail does not do any automatic encoding of binary data. Refer to the documentation for Mail Tool or dtmail for information on how to encode and decode electronic mail messages.

Message Delivery

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

The sendmail program sends the message to the delivery agent with one of the same interfaces used to submit a message to sendmail (using the conventional UNIX argument vector/return status, speaking over a pair of UNIX pipes and speaking SMTP over a TCP connection). Each copy of the message has a customized header attached to the beginning of it. The delivery agent catches and checks the status code, and a suitable error message is given as appropriate. The exit code must conform to a system standard. If a nonstandard exit code is used, the message Services unavailable is used.

Queuing for Retransmission

When the delivery agent returns a status that shows it might be able to handle the mail later (for example, the next host is down or the phone is busy for UUCP), sendmail stores it in a queue and tries again later.

Return to Sender

If errors occur during processing, sendmail returns the message to the sender for retransmission. The letter may be mailed back or written to the dead.letter file in the sender's home directory.

.forward Files

Users can create a .forward file in their home directory that sendmail uses to temporarily redirect mail or send mail to a custom set of programs. With a .forward file, users can redirect their mail without needing to bother a system administrator with frequent alias change requests. When troubleshooting mail problems, particularly problems of mail not being delivered to the expected address, always check the user's home directory for a .forward file.

Mail Delivery Agents

A mail delivery agent (or delivery agent) specifies a program external to sendmail that sendmail uses to deliver messages to various locations and for various purposes. The following list provides examples of delivery agents.

  • local—This delivery agent actually delivers an e-mail message into a user's mailbox, usually on a central mail hub system.

  • prog—This delivery agent enables an e-mail message to be passed into a program instead of into a mailbox.

  • smtp—This delivery agent does not actually call a program. Instead, it instructs sendmail to open a TCP network connection with another sendmail program running on another host. smtp enables sendmail to transmit messages to users that don't have a mailbox on the local system.

Delivery agents return the status of their deliveries to sendmail. If the delivery is successful, sendmail does no further work. If the delivery fails, then sendmail determines whether to requeue the message for another delivery attempt later or to bounce the message back to the original sender. sendmail makes this decision based on the status returned by the delivery agent.

Delivery agents are sometimes called mailers. This terminology is confusing because the m4 macros used to specify delivery agents in .mc files are called MAILERs. Therefore, we use the term delivery agent here. For more information, see "Mailers" on page 51.

  • + Share This
  • 🔖 Save To Your Account