Courie...:Module(3pm)

πŸ“¦
version 0.200 Β· 2 versions
, in debian bookworm, debian trixie

πŸ’– 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): returns Courier::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 β€” a Courier::Filter::Logger object 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 the match method gets negated by the consider method before it's returned. for the deets on how Courier::Filter translates match results into acceptability results, see "How filter modules work" in Courier::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 the trusted property in Courier::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 the match method, passing it the $message object. returns the result of match, 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 the Courier::Message object 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 by Courier::Filter, see "How filter modules work" in Courier::Filter::Overview and "Writing filter modules" in Courier::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: returns Courier::Filter::Logger
  • logger($logger): returns Courier::Filter::Logger β€” if $logger is 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's inverse option.
  • trusting: returns boolean β€” returns a boolean value indicating whether the filter module does not apply to trusted messages, as set through the constructor's trusting option.
  • testing: returns boolean β€” returns a boolean value indicating whether the filter module is in testing mode, as set through the constructor's testing option.
  • debugging: returns boolean
  • debugging($debugging): returns boolean β€” if $debugging is specified, sets the debugging mode for this individual filter module. returns the (newly) configured debugging mode.

πŸ”₯ SEE ALSO πŸ”₯

  • Courier::Filter
  • Courier::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