Recipe 9.6 Using a Queue Server

Problem

Special configuration is required to route mail to a queue server instead of queuing it locally.

Solution

Configure a system with a large amount of storage to act as a queue server. Configure the server to:

  • Have abundant queue storage. See Recipe 9.1 for information on creating multiple queues that span multiple physical devices.

  • Use a long queue interval. It should be at least one hour ; e.g., -q1h .

  • Act as a relay server for its queue clients. See Chapter 3 for information on granting relaying privileges to clients .

Configure clients to use the queue server using the confFALLBACK_MX define in the client's sendmail configuration. Assume that the queue server created in the first step is jamis.wrotethebook.com . Here is a sample define that could be added to the client's sendmail configuration to use that server:

 dnl Use jamis as the fallback mail exchanger define(`confFALLBACK_MX', `jamis.wrotethebook.com') 

Rebuild and install /etc/mail/sendmail.cf , then restart sendmail (see Recipe 1.8).

Discussion

MX records tell sendmail where to deliver mail. sendmail looks up the MX records for a recipient address. If there are no MX records for the recipient host, sendmail attempts to deliver to the recipient host itself using the host's address record or CNAME record. If DNS returns MX records for the recipient host, sendmail attempts to deliver mail to each mail exchanger in order. If none of these delivery attempts is successful, sendmail queues the mail. For example, imagine sendmail needs to deliver mail to wrotethebook.org and that the MX records provided are:

 wrotethebook.org.     IN     MX   10 mail.example.com. wrotethebook.org.     IN     MX   20 oreilly.com. 

sendmail first tries delivering the message to mail.example.com . If it works, sendmail is done. If delivery fails, it tries delivering to oreilly.com . [3] If that delivery fails, the mail is queued. confFALLBACK_MX changes this last step.

[3] MX records are looked up for every system in the MX list, except for the system added by the confFALLBACK_MX define.

The host defined by confFALLBACK_MX is treated as the mail-exchanger-of-last-resort for all deliveries. When mail cannot be successfully delivered to any of the mail exchangers listed on the MX records provided by DNS, sendmail sends the mail to the host specified by the confFALLBACK_MX define. If there are no MX records for the recipient host, sendmail attempts to send the mail using the host's A or CNAME record, and if that attempt fails, the mail is sent to the confFALLBACK_MX host. Additionally, if DNS does not respond to any of sendmail's queries for the recipient host's MX, A, or CNAME records, the mail is sent to the host defined by confFALLBACK_MX . All of this prevents the mail from being queued on the client.

When the fallback mail exchanger receives the mail, it treats it as mail being relayed to the recipient. This means that it will only accept the mail if the client has been granted relaying privileges. If the fallback mail exchanger accepts the mail, it retrieves the recipient's MX records from DNS and attempts delivery. If it is unable to deliver the mail, it queues it.

The advantage of this approach is that the bulk of systems (i.e., the clients) can be optimized to handle the average case, and the queue server can be optimized to handle queue processing. Recipe 9.7 describes one case of optimizing clients to operate in this environment. The disadvantage of using a queue server is that there are two failed delivery attempts before the mail is queued, although this does not result in any delay in delivering the mail.

A sendmail -bt test shows the effect of this recipe:

 #  sendmail -bt  ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> >  /mx aol.com  getmxrr(aol.com) returns 5 value(s):         mailin-02.mx.aol.com.         mailin-04.mx.aol.com.         mailin-03.mx.aol.com.         mailin-01.mx.aol.com.         jamis.wrotethebook.com. >  /mx sendmail.org  getmxrr(sendmail.org) returns 5 value(s):         smtp.neophilic.net.         services.sendmail.org.         smtp.gshapiro.net.         playground.sun.com.         jamis.wrotethebook.com. >  /quit  

The /mx command returns the MX list sendmail will use to deliver to the specified recipient host. No matter what recipient host is entered with the /mx command, the last system in the list is the host defined by confFALLBACK_MX .

See Also

Important background information for configuring a queue server is found in Chapter 3 and earlier in this chapter. The sendmail book covers confFALLBACK_MX in Section 24.9.45, and it provides an excellent discussion of using a queue server in Section 6.2.2. Section 6.3.1 of sendmail Performance Tuning , by Nick Christenson (Addison Wesley), provides additional information on using queue servers.



Sendmail Cookbook
sendmail Cookbook
ISBN: 0596004710
EAN: 2147483647
Year: 2005
Pages: 178
Authors: Craig Hunt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net