The check_compat Rule Set

Not all situations can be resolved by simply checking the RCPT To: or MAIL From: address. Sometimes you will need to make judgments based on pairs of addresses, or non-SMTP addresses or other information. To handle this situation, V8.8 introduced the check_compat rule set. Unlike check_mail and check_rcpt, check_compat is called for all deliveries, not just SMTP transactions. It is called after an address has undergone aliases translation, just after the check for too large a size (as defined by M=; see M= on page 746) and just before the checkcompat( ) routine (Appendix C on page 1248).

Note that although with V8.12 and later you can still write your own check_compat rule set, doing so has been made unnecessary by the FEATURE(compat_check) (FEATURE(compat_check)—V8.12 and Later on page 288). But also note that, as of V8.12, you cannot both declare the FEATURE(compat_check) and use this check_compat rule set.

The check_compat rule set is called with a workspace that looks like this:

sender $| recipient

The sender and recipient addresses are separated by the $| operator. Each has undergone aliasing and ~/.forward file processing.

One use for the check_compat rule set is to prevent a certain user (here, operator/) from sending mail offsite:

LOCAL_RULESETS SGet_domain R $* $: $>canonify $1 focus on host R $* <@ $+. > $* $1 <@ $2> $3 strip trailing dots R $* <@ $+ > $* $: $2 isolate the host R $* . $+ . $+ $2 . $3 strip host and subdomains SGet_user R $* $: $>3 $1 ...

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

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