Mail::...inDNSBL(3pm)

πŸ“¦
version 0.07 Β· 2 versions
, in debian bookworm, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 MATCHRECORD values, 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 inline sub{} β€” it gets called once for each address record returned by the DNSBL lookup. The subroutine should return 0 or undef to 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 with inet_ntoa() or unpack), and the domain name being checked by the DNSBL. 🫢

✨ accept_match(FLAG)

  • If FLAG is 0 β€” the default β€” a matching DNSBL will cause the mail to be rejected.
  • If FLAG is 1, a matching DNSBL makes this module return SMFIS_ACCEPT instead. That's what lets a MailDomainDNSBL live inside a Mail::Milter::Chain container (in accept_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 FLAG is 0 β€” the default β€” a DNSBL lookup that fails the underlying DNS query makes the milter return a temporary failure result: SMFIS_TEMPFAIL. 😭
  • If FLAG is 1, 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 NUM is positive, the recursion stops after NUM recursions.
  • If NUM is negative, the recursion stops once abs(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=1 will also check BAR.BAZ.COM
  • NUM=-1 will check BAR.BAZ.COM, BAZ.COM, and COM

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