Some rule sets are passed only a recipient or a sender address, supplied from either a header or the envelope. Examples are rule sets 1 and 2, and the rule sets indicated by the R= and S= equates. Other rule sets, such as the canonify rule set 3, can be called with any combination.

When designing rules, it might be necessary to know whether those rules are dealing with a sender or a recipient, and whether the address is from the envelope or a header. Beginning with V8.10, sendmail offers the ${addr_type} macro as a means to solve that very problem. As shown in Table 21-8 the ${addr_type} macro can hold any of several pairs of characters, depending on whether the address is from the envelope or a header, and whether the address is that of a sender or a recipient.

Table 21-8. Possible values for the {addr_type} macro



e s

An envelope sender address

e r

An envelope recipient address


A header recipient address or header sender address

To illustrate one use for this ${addr_type} macro’s value, consider a rule set that screens addresses and rejects any that are found in a database of spam sender hosts:

LOCAL_CONFIG Kspammers hash /etc/mail/spammers LOCAL_RULESETS SDomainLookup R $+ <@ $=w .> $@ OK local users are always OK R $+ <@ $+> $: $1 <@ $2 > <$&{addr_type}> R $+ <@ $+> <e r> $@ OK we only screen envelope senders. R $+ <@ $+> <h> $@ OK we don't screen header addresses. R $+ <@ $+> <$*> $(spammers $2 $: OK $) R OK $@ OK R $* $@ ERROR ...

Get Sendmail, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.