PH-Based Email Redirection with phquery

(Note: sendmail now contains native support for performing PH lookups using the ph map class. This new functionality is intended to replace phquery, since it does not require the overhead of forking multiple processes.)

phquery is a sendmail "plugin" which performs a ph lookup for the recipient's email field, and resubmits it to sendmail with the new address. This is illustrated in the diagram below.

Here's how to configure sendmail to use phquery:

  1. Install the phquery program (available with the qi source code).
  2. Create a mailertable which maps your top-level domain to the ph mailer (the uiuc.edu domain is used in the examples below):
    # cat > /etc/mailertable
    uiuc.edu	ph:uiuc.edu
    # makemap -v dbm /etc/mailertable < /etc/mailertable
    key=`uiuc.edu', val=`ph:uiuc.edu'
    
    makemap is distributed with sendmail. The exact syntax of the makemap command will vary depending on which database library you compiled sendmail and makemap with.
  3. Add these lines to your .mc file and regenerate sendmail.cf:
    FEATURE(`mailertable', `dbm -o /etc/mailertable')
    define(`PH_MAILER_PATH', `/usr/local/sbin/phquery')dnl
    MAILER(`phquery')
    
    The exact syntax of the mailertable line will vary dependong on which database library you compiled sendmail with. The definition of PH_MAILER_PATH should be set to the location in which you installed phquery.
  4. Restart sendmail, and you're ready to go.

Mark D. Roth <roth@feep.net>