sendmail ph Map Class Support


Introduction

Traditionally, PH-Based Email Redirection was done using the phquery program. This method involved three processes: the message is received by sendmail, which invokes phquery to do the PH lookup, which then invokes a new copy of sendmail to send the message to the rewritten address. The overhead of all that forking can place a high load on machines which do frequent PH lookups, such as the campus mail relays at UIUC.

In addition, the phquery program is very old. The code isn't very readable or maintainable, and the configuration isn't very flexible.

To solve these problems, I've added PH lookup functionality to the sendmail binary itself in the form of a ph map class. Using this code eliminates the need for the external phquery process. I've also added some sendmail configuration macros to make PH redirection much more flexible.


Building

NOTE: These instructions assume that the reader is already familiar with using and building sendmail. They explain only the settings which are specific to building sendmail with ph map class support.

  1. Download and install the PH client package, nph. This will install the libphclient library.

  2. Download and extract the sendmail source code.

  3. Add these lines to your devtools/Site/site.config.m4 file:
    APPENDDEF(`confMAPDEF', `-DPH_MAP')dnl
    APPENDDEF(`confINCDIRS', `-I/path/to/phclient/hdrs')dnl
    APPENDDEF(`confLIBDIRS', `-L/path/to/phclient/libs')dnl
    APPENDDEF(`confLIBS', `-lphclient')dnl
    
    Replace /path/to/phclient/hdrs with the include path which contains the phclient.h file (e.g., /usr/local/include). Also replace /path/to/phclient/libs with the path which contains the libphclient.a library (e.g., /usr/local/lib).

    If you are building sendmail-8.12.x with nph-1.2.x, you also need to add this line:

    APPENDDEF(`confMAPDEF', `-DNPH_VERSION=10200')dnl
    
  4. Now build and install sendmail as usual using the Build script.


Macro Configuration

The easiest way to use the ph map class is via the
FEATURE(domainmap) Macro, which you must download and install seperately. Here is a sample line for a sendmail.mc file which uses this macro to configure a ph map:
FEATURE(domainmap, `uiuc.edu', `ph -l 30 -h phquery.uiuc.edu')dnl

If you are changing an existing sendmail.mc file to use a ph map instead of phquery, you need to remove the macros which relate to phquery. This includes any of the following:

define(`PH_MAILER_FLAGS', ...)
define(`PH_MAILER_ARGS', ...)
MAILER(phquery)
Also, you do not need to use a mailertable to tell sendmail when to invoke phquery. If that is the only purpose of your mailertable, you should remove its definition from your sendmail.mc file. If you use a mailertable for other things, make sure it does not have an entry for the ph mailer.


How It Works

Here's the syntax for the ph map class:
K map_name ph [-l timeout] [-k "field1 field2 ..."] -h "host1 host2 ..."
The semantics of the ph map class are very similar to that of the ldap map class. The -h option, which specifies a quoted, space-delimited list of PH servers to try, is mandatory.

The -l flag specifies the number of seconds after which a connection to the PH server or a particular query will timeout. (This option is available in 8.10 and 8.11 using _FFR_PHMAP_TIMEOUT, and in the new libphclient code. It is not available in older versions.)

You can use the -k option to specify a quoted, space-delimited list of fields to query from the PH server. If not specified, the list of fields is obtained from the mailmatches field in the PH server's siteinfo list. If that isn't available, the default is provided by libphclient. (In older versions, -v was used instead. Also note that the "spacedname" pseudo-field name that was used by the old libqiapi code is no longer understood.)


Version History

sendmail-8.12.7
Support for libphclient-1.2.x integrated into sendmail source distribution.

sendmail-8.12.6-nph-1.2-API.diff

sendmail-8.12.0
New libphclient code integrated into sendmail source distribution.

sendmail-8.11.6-libphclient-phmap-20010529.diff
No changes.

sendmail-8.11.4-libphclient-phmap-20010529.diff

sendmail-8.11.2-libphclient-phmap-20000914.diff

sendmail-8.11.1-libphclient-phmap-20000914.diff

sendmail-8.11.0-libphclient-phmap-20000720.diff

sendmail-8.10.0-libphclient-phmap-20000402.diff

sendmail-8.10.0-libphclient-phmap.diff

sendmail-8.11.1

sendmail-8.10.0

sendmail-8.9.3-phmap-7.diff

sendmail-8.9.3-phmap-6.diff

sendmail-8.9.3-phmap-5.diff

sendmail-8.9.3-phmap-4.diff

sendmail-8.9.3-phmap-3.diff

sendmail-8.9.3-phmap-2.diff

sendmail-8.9.3-phmap-1.diff
Initial release.

Mark D. Roth <roth@feep.net>