Mailmun...Greylist(3)
π Mailmunge::Test::Greylist β the greylisting one, bestie
okay so this is a page from the User Contributed Perl Documentation manual (that's the manual name, we're not typing the whole header line out again, we're not monsters) and it's all about Mailmunge::Test::Greylist, a Perl class that does greylisting. Let's get into it β¨
πΈ NAME
Mailmunge::Test::Greylist β the implementation of greylist. that's it, that's the name, she's literally named what she does π
π ABSTRACT
So what does this class actually do? It implements greylisting: it temporarily-fails a combination of machine, sender, and recipient (and possibly other data, iykyk) that it has never seen before. Like, it's giving "new phone who dis" but for SMTP. π«Ά
Also important: Mailmunge::Test::Greylist is a subclass of Mailmunge::Test. family tree, established. π
β¨ SYNOPSIS
here's the whole vibe in code form. no cap, this is the real thing:
# A database must have been created beforehand with
# the following schema:
#
# CREATE TABLE greylist(hash TEXT PRIMARY KEY NOT NULL, last_seen INTEGER);
# CREATE TABLE ips_known_to_retry(ip TEXT PRIMARY KEY NOT NULL, last_seen INTEGER);
my $dbh;
sub initialize {
# Always connect to the database in the "initialize" callback
$dbh = DBI->connect($dsn, $username, $auth, {attr => val});
}
sub cleanup {
# Tidy up when our filter is about to exit
$dbh->disconnect;
}
# The actual use of Mailmunge::Test::Greylist
sub filter_recipient {
my ($ctx) = @_;
my $gl = Mailmunge::Test::Greylist->new($self);
my $min_delay = 5;
my $max_delay = 86400;
my $result = $gl->evaluate($dbh, $min_delay, $max_delay,
$ctx->hostip, $ctx->sender,
$ctx->recipients->[0]);
return $result unless $result->is_success;
# ...
}
okay but the first thing, before any of that: a database must have already been created beforehand with that schema up there. β οΈ the two CREATE TABLE lines β one for greylist and one for ips_known_to_retry β that's the setup, don't skip it.
π CONSTRUCTOR
β Mailmunge::Test::Greylist->new($filter)
Constructs and returns a new Mailmunge::Test::Greylist object. that's it. she's born. iconic. π
π₯ METHODS
π evaluate($dbh, $min_delay, $max_delay, $ip, @remaining_args)
This is the main character method. It evaluates greylisting and returns a Mailmunge::Response object that will either be CONTINUE or TEMPFAIL. Those are the only two options, bestie, pick a lane. π¦
here's what every argument is doing at the function:
$dbhis a DBI handle connected to the greylisting database. database said hi. π$min_delayand$max_delayare the imposed minimum and maximum retry delays respectively. so here's the tea: if an SMTP client tries faster than the minimum delay, it continues to get greylisted (sorry babe, too eager π). and if it waits longer than the maximum delay, it begins the greylisting test from scratch (back to square one, we love a reset π).$ipis the IP address of the connecting SMTP client. that's the machine in the machine/sender/recipient combo. π₯οΈ@remaining_argsare any other arguments that should be considered to make the greylist tuple specific. typically you'd callevaluatefromfilter_recipientand would pass the sender and recipient as@remaining_args. so like, the extra seasoning that makes this tuple this tuple. π
π AUTHOR
Dianne Skoll <dianne@skollsoft.com> β mother of this code, we stan. π
π§ LICENSE
This code is licenced under the terms of the GNU General Public License, version 2. periodt. π (note: the original spells it "licenced", spelling icon behavior, we don't correct legends)
π quick reminder before you go: the synopsis schema is not optional, always connect in theinitializecallback, and tidy up with$dbh->disconnectincleanup. the vibes are immaculate but the database has to exist first, fr fr.
okay that's the page!! this was rendered by perl v5.42.2 on 2025-10-05, and hey, if a manual page like this can slay, so can you. mwah π
ππΈ
π¦ where this page comes from
- alpine 3.24: mailmunge-doc 3.20-r0 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms