# check for junk domain/spammers Sjunk # lookup domain in database R$*<@$+>$* $:$1<@$(junk $2$)>$3 # exists? return R$*<@JUNK>$* $@$1<@JUNK>$2 # lookup address in database R$*<@$+>$* $:$1<@$(junk $1@$2 $:$2$)>$3 # exists? return R$*<@SPAMMER>$* $@$1<@SPAMMER>$2 # mv one subdomain in front, try again R$*<@$-.$-.$+>$* $: $2<@> $>junk $1<@$3.$4>$5 # undo damage R$*<@>$*<@$+>$* $2<@$1.$3>$4This requires a database (map) which contains entries for well-known spammers in the form:
spammer@address.domain SPAMMERand for junk domains in the form
junk.domain JUNKThen it can be used in sendmail.cf as:
Kjunk dbm /etc/mail/junk(you may choose another database type and another location). This is now used in the ruleset as follows:
Scheck_mail
# don't check these
R<$*@$=w> $@ ok shortcut
# idea from Steven Schultz
R<> $: <$n @ $(dequote "" $&{client_name} $) >
R$* $: $>3 $1 canonify
R$- $@ ok local host
# no host without a . in the FQHN ?
R$*<@$->$* $#error $@ 5.1.8 $: 550 invalid host name $2, check your configuration.
# no DNS entry? this is dangerous!
# R$*<@$*$~P>$* $#error $@ 4.1.8 $: 451 unresolvable host name $2$3, check your setup.
# now remove the dot
R$*<@$*.>$* $: $1<@$2>$3
# and check the database
R$*<@$*>$* $: $>junk $1<@$2>$3
R$*<@$*JUNK>$* $#error $@ 5.7.1 $: "550 This domain is banned, contact your local admin." go away
R$*<@$*SPAMMER>$* $#error $@ 5.7.1 $: "550 You are banned, contact your local admin." go away
It is also available as
HACK(check_mail2)
in the
check.tar file
for use in a .mc file.
There are of course many variations how a database can be used. This is just one example. It could be simplified, if you don't need different error messages for banned domains and e-mail addresses (which is currently distinguished by the values SPAMMER and JUNK in the database).