HPlogo Sendmail 8.13.3 Programmer's Guide: HP-UX 11i v1 and HP-UX 11i v2 > Chapter 4 Configuring and Compiling Milter APIs

Configuring Milter in Sendmail

» 

Technical documentation

Complete book in PDF

 » Table of Contents

You must define a filter in your Sendmail configuration file and compile Sendmail.

To define a filter application in your Sendmail configuratin file, complete the following steps:

  1. You must add filters to your /usr/contrib/sendmail/etc/mail/cf/cf/generic-hpux-10.mc file. You can use the following commands to configure filters in the .mc file:

    MAIL_FILTER (‘name’, ‘equates’)
    INPUT_MAIL_FILTER(‘name’, ‘equates’)

    The MAIL_FILTER()command defines a filter with the given name and equates.

    For example, MAIL_FILTER(‘archive’, ‘S=local:/var/run/archivesock, F=R’)

    where:

    S=local:/var/run/archivesock, F=R

    Specifies the equates.

    archive

    Specifies name of the filter application.

    This command creates the following equivalent entry in the sendmail.cf file:

    Xarchive, S=local:/var/run/archivesock, F=R

    The INPUT_MAIL_FILTER() command performs the same action as the MAIL-FILTER command but INPUT_MAIL_FILTER also populates the m4 variable confINPUT_MAIL_FILTERS with the name of the filter such that the filter application is actually called by Sendmail.

  2. You can define the m4 variables or cf options to configure the Sendmail macros that are accessible through the smfi_getsymval() API.

    Table 4-1 “The mf Variables and cf Options” lists the different mf variables and cf options.

    Table 4-1 The mf Variables and cf Options

    The .mc FileThe .cf FileDefault Value
    confMILTER_MACROS_CONNECTMilter.macros.connectj, _, {daemon_name}, {if_name}, {if_addr}
    confMILTER_MACROS_HELOMilter.macros.helo{tls_version}, {cipher}, {cipher_bits}, {cert_subject}, {cert_issuer}
    confMILTER_MACROS_ENVFROMMilter.macros.envfromi, {auth_type}, {auth_authen}, {auth_ssf}, {auth_author}, {mail_mailer}, {mail_host}, {mail_addr}
    confMILTER_MACROS_ENVRCPTMilter.macros.envrcpt{rcpt_mailer}, {rcpt_host}, {rcpt_addr}

     

Following are the equates that you can include in the .mc file:

  • The required S= equate that specifies the socket where Sendmail must look for the filter.

  • The optional F= equate that specifies flags.

  • The optional T= equate that specifies timeouts.

All the equate names field names, and flag values are case sensitive.

Table 4-2 “The F= Equate Values” lists and describes the flag values for the F= equate.

Table 4-2 The F= Equate Values

FlagDescription
RRejects connection if the filter is not available.
TAborts connection temporarily if the filter is not available.

 

If a filter application is unavailable or unresponsive and you do not specify any flag in the /usr/contrib/sendmail/etc/mail/cf/cf/generic-hpux-10.mc file, Sendmail 8.13.3 continues with the normal handling of the current connection. For every new connection, Sendmail 8.13.3 attempts to contact the filter application again.

Table 4-3 The T= Equate Values

FlagDescription
CSpecifies the timeout value for connecting to a filter application. If you set C to 0, the system connect() timeout value is used. The default timeout value for C is 5 minutes.
SSpecifies the timeout value for sending information from Sendmail to a filter application. The default value for S is 10 seconds.
RSpecifies the timeout value for reading reply from the filter application. The default value for R is 10 seconds.
ESpecifies the overall timeout value between sending the end-of-message to the filter and waiting for the final acknowledgment. The default value for E is 5 minutes.

 

Table 4-3 “The T= Equate Values” lists and describes the different fields in the T= equate.

A semicolon (;) separates each field because a comma (,) already separates the equates.

The separator between each field is a semicolon (;) because a comma (,) already separates the equates. The value of each field is a decimal number followed by a single letter designating the units (s for seconds and m for minutes).

Following is an example of a myconfig.mc file, which contains 3 filters, namely filter1, filter2, and filter3:

INPUT_MAIL_FILTER(‘filter1’, ‘S=unix:/var/run/f1.sock, F=R’)
INPUT_MAIL_FILTER(‘filter2’, ‘S=unix:/var/run/f2.sock, F=T, T=S:1s;R:1s;E:5m’)
INPUT_MAIL_FILTER(‘filter3’, ‘S=inet:999@localhost, T=C:2m’)

define(‘confINPUT_MAIL_FILTERS’, ‘filter2,filter1,filter3’)

Run the following command to generate the configuration file, myconfig.cf:

m4 ../m4/cf.m4 myconfig.mc > myconfig.cf

These macros add the following entries to your Sendmail configuration file (sendmail.cf):

Xfilter1, S=unix:/var/run/f1.sock, F=R
Xfilter2, S=unix:/var/run/f2.sock, F=T, T=S:1s;R:1s;E:5m
Xfilter3, S=inet:999@localhost, T=C:2m

O InputMailFilters=filter2,filter1,filter3

By default, the filters run in the order defined in the .mc file. However, because confINPUT_MAIL_FILTERS is defined, the filters are run in the order “filter2, filter1, filter3”.

NOTE: You can use the MAIL_FILTER() command, instead of the INPUT_MAIL_FILTER() command, to define a filter without adding it to the input filter list.