Courie...:Module(3pm)
π NAME π
so like, Courier::Filter::Module is the abstract Perl base class for the filter modules that the Courier::Filter framework uses. it's giving "template energy" β you don't use it directly, you build on it π
πΈ SYNOPSIS πΈ
β¨ Courier::Filter message filtering β¨
use Courier::Filter::Module::My; # Need to use a non-abstract sub-class.
my $module = Courier::Filter::Module::My->new(
logger => $logger,
inverse => 0,
trusting => 0,
testing => 0,
debugging => 0
);
my $filter = Courier::Filter->new(
...
modules => [ $module ],
...
);
π¦ Deriving new filter module classes π¦
package Courier::Filter::Module::My;
use base qw(Courier::Filter::Module);
π DESCRIPTION π
okay so bestie, sub-classes of Courier::Filter::Module are what the Courier::Filter mail filtering framework uses to figure out whether a message is acceptable or not, like a vibe check but for mail π¬β¨. if you wanna know how filter modules get used in general, and how to actually write one, go read Courier::Filter::Overview.
heads up fr fr: when you override a method in a derived class, do not forget to call the inherited method from inside your overridden method. the way that this is important. don't skip it. π
π Constructor π
the following constructor is provided and may be overridden:
new(%options): returnsCourier::Filter::Moduleβ creates a new filter module using the%options. it initializes the filter module, which means opening I/O handles, connecting to databases, creating temporary files, initializing parser libraries, etc. π«
%options is a list of key/value pairs representing any of the following options:
loggerβ aCourier::Filter::Loggerobject that will be used for logging message rejections and error messages caused by this individual filter module. if you don't specify a logger,Courier::Filter's global logger gets used instead. no logger left behind π«Άinverseβ a boolean value controlling whether the filter module should operate with inverse polarity (true) as opposed to normal polarity (false). under inverse polarity, the result of thematchmethod gets negated by theconsidermethod before it's returned. for the deets on howCourier::Filtertranslates match results into acceptability results, see "How filter modules work" inCourier::Filter::Overview. defaults to false, periodt.trustingβ a boolean value controlling whether the filter module should not be applied to trusted messages. for details on how the trusted status is determined, see the description of thetrustedproperty inCourier::Message. in most configurations, this option can be used to white-list so-called outbound messages. defaults to false.testingβ a boolean value controlling whether the filter module should run in testing mode. in testing mode, planned message rejections will be logged as usual, but no messages will actually be rejected. defaults to false. it's giving "all talk no action" and honestly? iconic πdebuggingβ a boolean value controlling whether the filter module should log extra debugging information. defaults to false.
derived classes may support additional options, so don't come for me if your subclass has more β¨
Courier::Filter::Module::new() creates a hashref as an object of the invoked class, and stores the %options in it, but does nothing else. that's it. that's the whole thing. lowkey minimal queen.
π§ Destructor π§
the following destructor is provided and may be overridden:
destroyβ uninitializes the filter module, by closing I/O handles, disconnecting from databases, deleting temporary files, uninitializing parser libraries, etc..
Courier::Filter::Module::destroy() does nothing. sub-classes may override this method and define clean-up behavior. so like, it's your mess to tidy bestie π§Ή
π Class methods π
the following class methods are provided and may be overridden:
warn($text)β writes a warning message to syslog. this method may also be used as an instance method. versatile icon behavior π
π Instance methods π
the following instance methods are provided and may be overridden:
consider($message): returns string, [string]; throws Perl exceptions β calls thematchmethod, passing it the$messageobject. returns the result ofmatch, negating it beforehand if the filter module has inverse polarity. there is usually no need at all to override this method. like, seriously, leave it alone πmatch($message): returns string, [string]; throws Perl exceptions β examines theCourier::Messageobject given as$message. returns a so-called match result consisting of an SMTP status response text, and an optional numerical SMTP status response code. for details about how match results are used byCourier::Filter, see "How filter modules work" inCourier::Filter::Overviewand "Writing filter modules" inCourier::Filter::Overview.
Courier::Filter::Module::match() does nothing and returns undef. sub-classes should override this method and define their own matching rule β this is the main character method, the one you're actually here for π
logger: returnsCourier::Filter::Loggerlogger($logger): returnsCourier::Filter::Loggerβ if$loggeris specified, installs a new logger for this individual filter module. returns the current (new) logger.inverse: returns boolean β returns a boolean value indicating whether the filter module is operating with inverse polarity, as set through the constructor'sinverseoption.trusting: returns boolean β returns a boolean value indicating whether the filter module does not apply to trusted messages, as set through the constructor'strustingoption.testing: returns boolean β returns a boolean value indicating whether the filter module is in testing mode, as set through the constructor'stestingoption.debugging: returns booleandebugging($debugging): returns boolean β if$debuggingis specified, sets the debugging mode for this individual filter module. returns the (newly) configured debugging mode.
π₯ SEE ALSO π₯
Courier::FilterCourier::Filter::Module
for a list of prepared loggers that come with Courier::Filter, see "Bundled Courier::Filter loggers" in Courier::Filter::Overview.
for AVAILABILITY, SUPPORT, and LICENSE information, see Courier::Filter::Overview. yes bestie, that's where all the legal stuff lives πβ¨
π AUTHOR π
Julian Mehnle <julian@mehnle.net> β thank you for your service, king π«‘π
and that's the whole page, bestie! π this one came from perl v5.34.0, dated 2022-10-21, under the manual name Courie...:Module(3pm) in the User Contributed Perl Documentation section. you understood the assignment, now go write that filter module β¨π¦π
π¦ where this page comes from
- debian bookworm: courier-filter-perl 0.200+ds-6 Β· Artistic-1.0-Perl OR GPL-2.0-or-later
- debian trixie: courier-filter-perl 0.200+ds-6 Β· Artistic-1.0-Perl OR GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms