Continuing from the previous post in this series, let’s see how one can deal with incoming email that must be delivered both to physical users of the system and users not visible via /etc/passwd:
LOCAL_CONFIG Kuser user -m -a.FOUND LOCAL_RULE_0 # Unconditionally redirect email to abuse and Postmaster RPostmaster < @ $=w . > $* $: Postmaster < @example.com. > $3 Rabuse < @ $=w . > $* $: abuse < @example.com. > $3 # Deliver email to yiorgos locally Ryiorgos < @ $=w . > $* $# local $: $1 # Delete email directed to all other users in /etc/passwd R$- < @ $=w . > $* $(user $1 $) R$- . FOUND $#local $: bit-bucket # The following is valid only if sendmail is instructed to not check /etc/passwd. # This is achieved with MODIFY_MAILER_FLAGS(`LOCAL', `-w')dnl R$- < @ $=w . > $* $#custom.local $: $1
What does the above snippet do? The first set of rules accepts all incoming email addressed to Postmaster and abuse and redirects it to Postmaster@example.com and firstname.lastname@example.org.
The second set of rules accepts and delivers locally all incoming email addressed to user yiorgos.
The third set deletes all incoming email for all other users listed in /etc/passwd. One may refine that using a (sendmail) class definition and decide to do so for incoming email addressed to users like man, daemon, lp etc. Remember that in Ruleset 0 you cannot call $#discard.
Assuming that you have written a special delivery agent (to save email in a database for example) for “local” users not found in /etc/passwd, the last rule calls that delivery agent for the given username.
Of course if you are in a certain mood of BOFHiness, you can add similar rules that return random error codes to the sender. The expressiveness of sendmail’s modem-noise is unlimited…