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.
- Download and install the PH client package, nph. This will
install the libphclient library.
- Download and extract the
sendmail
source code.
- 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
- 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
- added support for libphclient-1.2.x (build with
-DNPH_VERSION=10200)
- 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
- added libphclient version to ph_id() version string
- use -k instead of -v in map definition
- sendmail-8.11.2-libphclient-phmap-20000914.diff
- removed duplicate code block accidentally added in 8.11.1 patch
- sendmail-8.11.1-libphclient-phmap-20000914.diff
- initialize ph_id() version string in ph_map_init()
instead of in ph_map_open()
- updated to use new ph_open() interface
- sendmail-8.11.0-libphclient-phmap-20000720.diff
- clear libphclient send and receive hooks before
calling ph_close()
- sendmail-8.10.0-libphclient-phmap-20000402.diff
- added sendmail version and ph map version to
ph_id() version string
- fix handling of ph_email_resolve() return value
- sendmail-8.10.0-libphclient-phmap.diff
- rewrote PH map code using libphclient instead of
libqiapi
- sendmail-8.11.1
- queue messages instead of bouncing when a temp failure occurs (like
the PH server being down)
- sendmail-8.10.0
- ph map code officially integrated into sendmail
source distribution.
- If an alias lookup matches a single entry, but that entry
has no email field, the code continued on to try
the remaining selected lookup types. This would often cause the
email to be mistakenly delivered to a different user by a successful
spacedname lookup. Instead, it now bounces
the message as soon as it finds the alias match.
- If the email field of a selected entry has more than one
email address listed on the same line, the code would fail to chop
the second address off. Both addresses would be returned as if they
were one, and the email would be bounced because of the invalid address.
- There was no way to set a timeout for communication with the server,
so the code would block indefinitely while opening the connection or
performing a lookup. (This is provided via
_FFR_PHMAP_TIMEOUT in 8.10.)
- sendmail-8.9.3-phmap-7.diff
- Removed PH_DOMAIN_MAP() macro in favor of FEATURE(domainmap) (distributed seperately)
- sendmail-8.9.3-phmap-6.diff
- when primary server fails to initialize, close connection before falling back to secondary server
- convert all punctuation characters to "-" for alias field lookups
- added spacedname pseudo-field: converts all punctuation except for "*" to spaces and performs name field lookup
- tweaked error reporting
- sendmail-8.9.3-phmap-5.diff
- tweaked error reporting
- fixed handling of temporary failures (was bouncing, not deferring)
- sendmail-8.9.3-phmap-4.diff
- fixed segfault in ph_map_close() (check for open connection before trying to close)
- sendmail-8.9.3-phmap-3.diff
- fixed handling of LOCAL_USERS()
- fixed handling of recursive resolution
- sendmail-8.9.3-phmap-2.diff
- added "PH_MAP" to CompileOptions array
- removed setting of ph port (the libqiapi API doesn't allow this)
- allow space-delimited list of fields to query
- changed to not connect to qi until lookup time, and keep connection open until the map is closed
- sendmail-8.9.3-phmap-1.diff
- Initial release.
Mark D. Roth <roth@feep.net>