${nbadrcpts}

Number of bad envelope recipients V8.13 and later

When sendmail receives an SMTP RCPT To: command, it examines the recipient address contained in that command, then accepts known local recipients and rejects other recipients. If relaying is enabled for selected hosts, envelope recipients addressed to those hosts are also allowed. If the address is disallowed, the message is rejected by sendmail and neither rule sets nor Milters ever see it.

If knowing the number of rejected recipients for a given envelope is important to you, you may access that number using this ${nbadrcpts} macro.

If used in rule sets, the ${nbadrcpts} macro will contain only a true total after all envelope recipients have been processed. Thus, a good place to use it might be in the check_data rule set (check_data on page 705) which is called after the SMTP DATA command is received, but before that command is acknowledged (in other words, after all recipients have been processed):

LOCAL_RULESETS
Scheck_data
R $*                     $: $&{nbadrcpts}
R $+                     $: $(arith l $@ $1 $@ 25 $)
R FALSE            $# error $@ 5.1.2 $: "553 Too many bad recipients"

Here, under the LOCAL_RULESETS portion of your mc configuration file, you first declare the check_data rule set, which contains three rules. The first rule simply matches anything on the LHS (the $*) and places the value of this ${nbadrcpts} macro into the workspace. The second rule compares that value (using the arith database map; see arith on page 898) to the literal value 25. If the ...

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.