Macros in Rule Set Names

Macros can be used in any or all of a part of a rule set declaration. They can be used to declare a name:

D{NAME}myname
S${NAME}

or to declare a number:

D{NUMBER}12
S${NUMBER}

or both a name and a number:

D{NAME}myname
D{NUMBER}12
S${NAME}=${NUMBER}

or even the whole thing:

D{SET}myset=12
S${SET}

You can use single- and multicharacter sendmail macros in any combination. Macros can be used in any rule set declaration, including subroutine calls inside rules:

R $* < $=w > $*       $@ $>${NAME} $2

But they cannot be used in the S= or the R= of delivery agents:

Mprog, P=sh, ..., S=$X, R=$X, ...
                    ↑     ↑
                    neither of these will work

Macros can be used in the command line to modify a configuration file when sendmail is run. Consider the desire to call one rule set when running as a daemon and another when processing the queue. You might declare such rules like this:

R $*            $: $&A
R daemon        $@ $>Daemon_ruleset
R queue         $@ $>Queue_ruleset
R $*            $@ $>UndefinedA_ruleset

The two different runs might look like this:

# /usr/sbin/sendmail -MAdaemon -bd
# /usr/sbin/sendmail -MAqueue -q30m

The first defines the $A sendmail macro to have the value daemon and results in this subroutine call:

R daemon        $@ $>Daemon_ruleset

The second defines the $A sendmail macro to have the value queue and results in this different subroutine call:

R queue         $@ $>Queue_ruleset

Note that any different or missing command-line setting for $A will result in the fallback subroutine call:

R $*            $@ $>UndefinedA_ruleset

Also note that you can ...

Get sendmail, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.