Mail::...tDNSBL(3pm)
π Mail::Milter::Module::ConnectDNSBL π
okay bestie, welcome to the Mail::Milter::Module::ConnectDNSBL page from the Perl docs, aka a whole milter module that checks connecting hosts against DNSBLs and decides whether to let them in or shut the door π
it's part of the Mail::Milter family and it's literally giving bouncer-at-the-club energy. let's get into it β¨
πΈ NAME πΈ
Mail::Milter::Module::ConnectDNSBL β a milter to accept/reject connecting hosts matching DNSBLs. yes, that's the whole vibe: check the connecting host, match it against a DNS Blocking List, accept or reject. iconic.
β¨ SYNOPSIS β¨
use Mail::Milter::Module::ConnectDNSBL;
my $milter = new Mail::Milter::Module::ConnectDNSBL('foo.spamlist.dom');
my $milter2 = &ConnectDNSBL('foo.spamlist.dom'); # convenience
$milter2->set_message('Connections from %A disallowed');
so you use it, you make one with a DNSBL root host, you can also call it the shortcut way with &ConnectDNSBL(...) (that's the convenience form, love that for us), and then you can set_message to customize the rejection text. cute, right? π
π¦ DESCRIPTION π¦
This milter module rejects any connecting host whose IPv4 address matches a given DNS Blocking List (DNSBL). and lowkey it can do the opposite too β it can function as a whitelisting Chain element; see "accept_match()" for that whole situation. main character energy either way π
The check used by this module is a simple "A" record lookup, via the standard "gethostbyname" lookup mechanism. The way it does NOT need Net::DNS? obsessed. that's why it's typically very fast, no cap. β‘
Note: If the connecting host is not using IPv4, this module will simply be a passthrough using SMFIS_CONTINUE. so like, nothing happens, it just moves on. fr fr.
π METHODS π
new(DNSBL)new(DNSBL, MATCHRECORD[, ...])new(DNSBL, SUBREF)
Creates a ConnectDNSBL object. DNSBL is the root host hierarchy to use for lookups. Three methods of matching can be used:
- If no additional arguments are provided, the match succeeds if there is any address entry present for the DNSBL lookup; the values are not examined. like, presence alone is enough bestie.
- If one or more
MATCHRECORDvalues are supplied, they are string representations of IPv4 addresses. If any of these match record values is the same as any address record returned by the DNSBL lookup, the match succeeds. so you're basically listing the exact addresses that should trigger it. - If a
SUBREF(reference to a subroutine; may be an anonymous inlinesub{}) is supplied, it is called for each of the address records returned by the DNSBL lookup. The subroutine should return0orundefto indicate a failed match, and nonzero to indicate a successful match. The subroutine receives a binary-encoded four byte scalar that should be transformed as needed withinet_ntoa()orunpack. so much power in your hands, use it wisely π«Ά
accept_match(FLAG)- If
FLAGis0(the default), a matching DNSBL will cause the connection to be rejected. the classic blacklist behavior. - If
FLAGis1, a matching DNSBL will cause this module to returnSMFIS_ACCEPTinstead. This allows a"ConnectDNSBL"to be used inside a"Mail::Milter::Chain"container (inaccept_break(1)mode), to function as a whitelist rather than a blacklist. plot twist! π
- If
This method returns a reference to the object itself, allowing this method call to be chained. chain it, bestie, it's giving fluent interface π
ignore_tempfail(FLAG)- If
FLAGis0(the default), a DNSBL lookup which fails the underlying DNS query will cause the milter to return a temporary failure result (SMFIS_TEMPFAIL). - If
FLAGis1, a temporary DNS failure will be treated as if the lookup resulted in an empty record set (SMFIS_CONTINUE). so instead of tempfailing, it just... shrugs and continues. π
- If
This method returns a reference to the object itself, allowing this method call to be chained. yes, chainable too, slay.
set_message(MESSAGE)
Sets the message used when rejecting connections. This string may contain the substring %A, which will be replaced by the matching IPv4 address, or %L, which will be replaced by the name of the matching DNSBL. so your rejection message can be all personalized and cute β¨
This method returns a reference to the object itself, allowing this method call to be chained. (yes, everything here chains, it's a whole aesthetic.)
π BUGS π
In Sendmail 8.11 and 8.12, a milter rejection at "connect" stage does not allow the reply message to be set β it simply becomes "not accepting messages". However, this module still attempts to set the reply code and message in the hope that this will be fixed.
so like, it's a known thing, not a fix, just a hopeful little attempt. respect honestly. π
π AUTHOR π
Todd Vierling, <tv@duh.org> <tv@pobox.com> β thank you for your service, legend π«Ά
π₯ SEE ALSO π₯
Mail::Milter::Object
π§ POD ERRORS π§
Hey! The above document had some coding errors, which are explained below:
- Around line 79:
You can't have =items (as at line 91) unless the first thing after
the =over is an =item
yeah, the doc itself got caught slipping by the POD parser, but we still love her π
okay so that's the whole page, bestie, every option, every flag, every default, every %A and %L, every exit code, all of it β preserved exactly π this was perl v5.36.0, dated 2023-01-22, and it's the Mail::...tDNSBL(3pm) page, so go forth and filter those connections. periodt. π
β¨
π¦ 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