Free Programming Books
Free download ebooks on computer and programming | |||
Free Ebook "sendmail Cookbook" Sample Chapter
sendmail Cookbook
Download chapter
Free download Chapter 2: Delivery and Forwarding The sendmail Cookbook provides step-by-step solutions for the administrator who needs to solve configuration problems fast. Each recipe in the sendmail Cookbook outlines a configuration problem, presents the configuration code that solves that problem, and then explains the code in detail. The book also provides lots of new material that doesn't get much coverage elsewhere--STARTTLS and AUTH are given entire chapters, and LDAP is covered in recipes throughout the book. Delivery and Forwarding
2.0 IntroductionInbound mail is either delivered directly to the addressee or relayed to another mail host for delivery. Mail is directly delivered only if it is destined for the local host; mail destined for any other host is relayed. In this chapter, we look at ways to properly configure sendmail to deliver mail locally and forward it to other systems. Delivery is a multistep process. First, sendmail must process the host portion of the delivery address and recognize that the mail is, in fact, addressed to the local host. If it isn’t addressed to the local host, it is relayed as described in Chapter 3. If it is addressed to the local host, the user portion of the address is processed against the aliases file to determine the proper delivery address. If the aliases file returns an external address, the mail is forwarded to the external host for delivery. If it returns the address of a local mailbox, sendmail checks for a .forward file. If the .forward file exists, the mail is delivered as specified by that file. Otherwise, the mail is delivered to the local mailbox. Figure 2-1 illustrates this delivery flow.* sendmail processes each delivery address through the canonify ruleset and through the parse ruleset—rulesets 3 and 0. Aliasing starts when the result of that process tells sendmail to deliver the mail through a mailer that has the A flag set.† If ruleset 0 returns the name of a mailer that does not have the A flag set, aliasing is not done. While the A flag can be set for any mailer, only the cyrus mailers and the local mailer set the A flag by default. For our discussion of aliasing, we’ll use the local mailer as an example. Aliasing first looks up the delivery address in the aliases database. If the lookup returns a different email address, the new address is processed. If the mailer used for the new address has the A flag set, that address is looked up in the aliases database. This process continues until no new address is returned by the alias lookup. If the mailer used for the final address returned by the aliases database has the w flag set, sendmail looks for a delivery address in the user’s .forward file. By default, only the local mailer has the w flag set. If a .forward file is found, delivery is made based on the delivery address that it contains. Although Figure 2-1 portrays a simplified version of the actual delivery process, it does highlight areas of the configuration that relate to local delivery and forwarding. Class $=w must be properly configured. The aliases file must be created and made into a database, and, if used, the .forward files must be properly configured. sendmail only accepts mail for local delivery that is addressed to the local host. All other mail is relayed. Class $=w contains all of the valid hostnames for the local host. If the hostname from the delivery address is found in class $=w, the mail is accepted for local delivery. In fact, ruleset 0 uses class $=w when selecting the local mailer. Mail delivered by the local mailer must be addressed to a user account that exists on the local host or to an alias that resolves to a valid delivery address. The aliases database frees the local mailer from the limitation of having all local mail addressed to actual usernames. It makes sendmail a more flexible system by allowing mail addressed to a single alias to be sent to multiple recipients or mail addressed to several different names to be routed to a single recipient. The aliases database is also used to forward mail to other computers, programs, and files. The aliases database is so essential to the functioning of a sendmail system that sendmail complains if the database does not exist. Some users and programs that send out email alerts may also complain because they assume that certain aliases exist. Additionally, if neither the aliases database nor the aliases text file is found, sendmail will not apply the user’s .forward file. When sendmail looks up a local address in the aliases database and no new recipient address is returned by the lookup, sendmail checks to see if the user identified by the local address has a .forward file. | |||