Mail::...inDNSBL(3pm)
π Mail::...inDNSBL(3pm) β the girlies' guide π
okay so bestie, this is a page from the User Contributed Perl Documentation collection, and it's all about one lil milter module that's about to become your new obsession. it's giving gatekeeper energy, but for spam. π«β¨
πΈ NAME πΈ
Mail::Milter::Module::MailDomainDNSBL β a milter that accepts or rejects mail when the sender's domain matches a DNSBL. no cap, that's the whole vibe.
π SYNOPSIS π
use Mail::Milter::Module::MailDomainDNSBL;
my $milter = new Mail::Milter::Module::MailDomainDNSBL('foo.spamlist.dom');
my $milter2 = &MailDomainDNSBL('foo.spamlist.dom'); # convenience
$milter2->set_message('Mail from %M disallowed');
like, literally four lines and you're already iconic. π
π¦ DESCRIPTION π¦
This milter module rejects any mail coming from a sender's domain β and bestie, listen, it's the domain in the MAIL FROM part of the SMTP transaction, not the one in the From: header, okay? those are two totally different things and the way people mix them upβ¦ anyway π β that matches a given DNS Blocking List (DNSBL).
It can also serve as a whitelisting element inside a Chain. see accept_match() for that whole situation. iykyk.
fun fact fr fr: in some anti-spam lingo, this whole thing is known as a "RHSBL" check. β¨
The check this module does is a simple A record lookup, run through the standard gethostbyname lookup mechanism. It does not need Net::DNS, which means it's typically very fast. slay. β‘
π METHODS π
β¨ new(DNSBL)
β¨ new(DNSBL, MATCHRECORD[, ...])
β¨ new(DNSBL, SUBREF)
Creates a MailDomainDNSBL object. DNSBL is the root host hierarchy you're using for lookups. There are three ways to match, pick your fighter:
- If you pass no additional arguments, the match succeeds whenever any address entry is present for the DNSBL lookup. the values themselves? not examined. not even looked at. we don't care. π
- If you supply one or more
MATCHRECORDvalues, they're string representations of IPv4 addresses. If any of those match record values equals any address record returned by the DNSBL lookup, the match succeeds. π― - If you supply a
SUBREFβ a reference to a subroutine, and yes it can be an anonymous inlinesub{}β it gets called once for each address record returned by the DNSBL lookup. The subroutine should return0orundefto say "nope, failed match", and nonzero to say "yesss, successful match". It receives two arguments: a binary-encoded four byte scalar (transform it as needed withinet_ntoa()orunpack), and the domain name being checked by the DNSBL. π«Ά
β¨ accept_match(FLAG)
- If
FLAGis0β the default β a matching DNSBL will cause the mail to be rejected. - If
FLAGis1, a matching DNSBL makes this module returnSMFIS_ACCEPTinstead. That's what lets aMailDomainDNSBLlive inside aMail::Milter::Chaincontainer (inaccept_break(1)mode) and act as a whitelist instead of a blacklist. glow up π
This method returns a reference to the object itself, so you can chain those calls. periodt.
β¨ ignore_tempfail(FLAG)
- If
FLAGis0β the default β a DNSBL lookup that fails the underlying DNS query makes the milter return a temporary failure result:SMFIS_TEMPFAIL. π - If
FLAGis1, a temporary DNS failure gets treated like the lookup came back with an empty record set:SMFIS_CONTINUE. shrug emoji, we move on. π
This method returns a reference to the object itself, so chain away.
β¨ check_superdomains(NUM)
If checking the domain name verbatim gives you no match, this recurses one level upward at a time and tries the check again.
- If
NUMis positive, the recursion stops afterNUMrecursions. - If
NUMis negative, the recursion stops onceabs(NUM)domain levels have been reached. - The default is
0, meaning no recursion happens at all.
Example time, bestie β when checking the domain name FOO.BAR.BAZ.COM:
NUM=1will also checkBAR.BAZ.COMNUM=-1will checkBAR.BAZ.COM,BAZ.COM, andCOM
This method returns a reference to the object itself, allowing this method call to be chained. π
β¨ set_message(MESSAGE)
Sets the message used when rejecting messages. This string may contain the substring %M, which gets replaced by the matching e-mail address, or %L, which gets replaced by the name of the matching DNSBL. custom rejection messages = main character energy. π
This method returns a reference to the object itself, allowing this method call to be chained.
β AUTHOR β
Todd Vierling, <tv@duh.org> <tv@pobox.com>
π SEE ALSO π
Mail::Milter::Object
π POD ERRORS π
not to be dramatic but⦠hey! the above document had some coding errors, which are explained below:
Around line 78:
You can't have =items (as at line 90) unless the first thing after
the =over is an =item
ngl the docs did a little fumble. we still love her. π
and that's the whole page, bestie!! this one's perl v5.36.0, dated 2023-01-22, filed under Mail::...inDNSBL(3pm) β go forth and filter those domains, you absolute queen ππβ¨
π¦ where this page comes from
- debian bookworm: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu noble: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu resolute: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu stonking: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms