Recipe 5.1 Routing Mail to Special Purpose Mailers

Problem

You have been asked to configure sendmail to deal with specific remote systems that cannot handle standard Extended SMTP mail.

Solution

Build a mailertable database that routes mail bound for specific remote systems through the appropriate special-purpose mailers. Do this by first creating a text file and then processing that file with the makemap script to create a hash type map. The key for these mailertable entries is a full or partial domain name that must match the hostname part of the recipient address on mail that needs to be handled by a special-purpose mailer. The return value is the internal name of the special-purpose mailer separated by a colon from the name of the remote system that will accept the mail.

Add the mailertable feature to the sendmail configuration. Here is the required mailertable FEATURE macro:

 dnl Add support for the mailertable FEATURE(`mailertable') 

Build the sendmail.cf file. Copy it to /etc/mail , and restart sendmail. See Recipe Recipe 1.8 for an example.

Discussion

A basic sendmail configuration contains MAILER macros that load local.m4 and smtp.m4 . The local MAILER macro adds the prog and local mailers to the sendmail.cf configuration. The SMTP MAILER macro defines five mailers. Two, esmtp and relay , are essential for basic SMTP mail delivery. The three other mailers defined by the SMTP MAILER macro ( smtp8 , dsmtp , and smtp ) are not referenced by any mail delivery triple in the sendmail.cf file. The best way to make use of these unused mailers is through the mailertable .

For this example, assume that you must send mail to one remote system that cannot handle binary mail or the standard Extended SMTP syntax, and to other systems that can handle binary mail but cannot process the standard Extended SMTP syntax. Here is a sample mailertable with entries for these systems:

 #  cd /etc/mail  #  cat > mailertable   fakeu.edu         smtp8:mail.fakeu.edu   .falseu.edu       smtp8:ms.falseu.edu   .stateu.edu       smtp:mail.stateu.edu   new.stateu.edu    esmtp:new.stateu.edu   Ctrl-D  #  makemap hash mailertable < mailertable  

The first two sample mailertable entries use the smtp8 mailer ”a special SMTP mailer for use with a remote server that can handle binary mail but cannot handle the Extended SMTP protocol that is normally associated with binary mail. A simple test shows the impact of these mailertable entries:

 #  sendmail -bv -Cgeneric-linux.cf jeff@fakeu.edu  jeff@fakeu.edu... deliverable: mailer esmtp, host fakeu.edu., user jeff@fakeu.edu #  sendmail -bv -Cgeneric-linux.cf reba@foo.falseu.edu  reba@foo.falseu.edu... deliverable: mailer esmtp, host foo.falseu.edu, user reba@foo. falseu.edu #  sendmail -bv jeff@fakeu.edu  jeff@fakeu.edu... deliverable: mailer smtp8, host mail.fakeu.edu, user jeff@fakeu.edu #  sendmail -bv reba@foo.falseu.edu  reba@foo.falseu.edu... deliverable: mailer smtp8, host ms.falseu.edu, user reba@foo. falseu.edu #  sendmail -bv becky@falseu.edu  becky@falseu.edu... deliverable: mailer esmtp, host falseu.edu, user becky@falseu.edu 

The first two sendmail -bv tests show how a basic sendmail configuration routes mail to fakeu.edu and foo.falseu.edu . Rerunning these tests after this recipe is completed shows the impact of the mailertable . Notice the last two tests. Addresses in the form of user @ host .falseu.edu match the .falseu.edu mailertable entry and are processed as directed by that mailertable entry. However, mail addressed to user @falseu.edu does not match and thus is not processed by the mailertable in this example. The .falseu.edu mailertable entry defines a partial domain name. To control routing for both foo.falseu.edu and falseu.edu , put two entries in the mailertable ” one for the full domain name falseu.edu and one for the partial domain name .falseu.edu .

The last two entries in the sample mailertable use the smtp mailer and the esmtp mailer. The esmtp mailer is the default mailer used for most Internet mail. The smtp mailer implements the old version of the SMTP protocol that existed before Extended SMTP was created. The smtp mailer is only needed if the remote site cannot run Extended SMTP. The interesting thing about these two entries is that they contain overlapping references to the stateu.edu domain:

 .stateu.edu       smtp:mail.stateu.edu new.stateu.edu    esmtp:new.stateu.edu 

The first entry defines a partial domain name that will match any input hostname that ends in .stateu.edu . This appears to be in conflict with the second entry. The second entry exactly matches the hostname new.stateu.edu . However, new.stateu.edu also matches the first entry because it ends in .stateu.edu . Which entry will sendmail use to route mail addressed to new.stateu.edu ? In this case, it will use the second entry because that entry provides the most complete match, and the longest match takes precedence. This precedence is independent of the order in which the entries appear in the mailertable ” the longest match always takes precedence. These two lines, taken together, cause sendmail to use mail.stateu.edu as the host value for the mail delivery triple for all mail addressed to the stateu.edu domain with the exception of mail addressed to new.stateu.edu , which uses new.stateu.edu as the host value. new.stateu.edu is a modern system that handles standard Extended SMTP mail. Unfortunately, mail.stateu.edu is an outdated system that can only handle the obsolete SMTP protocol.

Alternatives

Updating the hardware and software of the target systems to fully support esmtp is a better alternative than using the mailertable to route mail through special mailers. If you have control of a destination system that must use a mailer like smtp or smtp8 to communicate with the outside world, replace it. Using outdated technology is a bad idea. Of course, you're not always in control of the remote system. For those times, the mailertable is an effective workaround.

See Also

Recipe 5.2 and Recipe 5.3 further describe mailertable features that you may wish to include in your mailertable . Recipe Recipe 5.4 provides additional information on rewriting the user address via the mailertable . The sendmail book covers the mailertable in Section 4.8.24. The cf/README file contains a Using Mailertables section.



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