Mail::...Client(3pm)
π NAME π
okay so bestie, welcome to Mail::SpamAssassin::Client β it's the Client for spamd Protocol, fr fr. she talks to spamd so you don't have to. π¦
β¨ SYNOPSIS β¨
here's the vibe β you can connect by port + host:
my $client = Mail::SpamAssassin::Client->new({
port => 783,
host => 'localhost',
username => 'someuser'});
or, if you're a socket girlie:
my $client = Mail::SpamAssassin::Client->new({
socketpath => '/path/to/socket',
username => 'someuser'});
pro tip moment: you can also pass timeout, which gets applied to IO::Socket for that first connection handshake. if you don't pass one? it defaults to 30 seconds. no cap. β±οΈ
then you ping to make sure your server's actually awake:
if ($client->ping()) {
print "Ping is ok\n";
}
and then you just... process the message. main character energy:
my $result = $client->process($testmsg);
if ($result->{isspam} eq 'True') {
do something with spam message here
}
like it's genuinely that simple, periodt. π
πΈ DESCRIPTION πΈ
Mail::SpamAssassin::Client is a module that gives you a perl implementation of the spamd protocol. that's it, that's the whole thing β she's a translator between your perl code and the spamd server. iconic behavior honestly. π
π PUBLIC METHODS π
π«Ά new
public class (Mail::SpamAssassin::Client) new (\% $args)
Description: this method creates a new Mail::SpamAssassin::Client object. fresh out the box, brand new, slay. β¨
π«Ά process
public instance (\%) process (String $msg)
Description: this method calls the spamd server with the PROCESS command.
the return value is a hash reference</> containing several pieces of information, if available:
content_lengthisspamscorethresholdmessagereport
π«Ά spam_report
public instance (\%) spam_report (String $msg)
Description: this method implements the report call.
see the process method for the return value. π
π«Ά spam_report_ifspam
public instance (\%) spam_report_ifspam (String $msg)
Description: this method implements the report_ifspam call. a report will be returned only if the message is spam. so if it's ham, don't hold your breath bestie. π
see the process method for the return value.
π«Ά check
public instance (\%) check (String $msg)
Description: this method implements the check call.
see the process method for the return value.
π«Ά headers
public instance (\%) headers (String $msg)
Description: this method implements the headers call.
see the process method for the return value.
π«Ά learn
public instance (Boolean) learn (String $msg, Integer $learntype)
Description: this method implements the learn call. $learntype should be an integer β 0 for spam, 1 for ham, and 2 for forget. the return value is a boolean telling you whether the message was learned or not.
β οΈ anundefreturn value means there was an error β check theresp_code/resp_msgvalues to figure out what went wrong. don't just ignore it, pls. π
π«Ά report
public instance (Boolean) report (String $msg)
Description: this method provides the report interface to spamd.
π«Ά revoke
public instance (Boolean) revoke (String $msg)
Description: this method provides the revoke interface to spamd.
π«Ά ping
public instance (Boolean) ping ()
Description: this method performs a server ping and returns 0 or 1 depending on whether the server responded correctly. vibe check for your server. β
π PRIVATE METHODS π
these are the backstage besties β internal machinery, not for public consumption. π
π§ _create_connection
private instance (IO::Socket) _create_connection ()
Description: this method sets up a proper IO::Socket connection based on the arguments you used when creating the client object.
if it fails, it sets an internal error code and returns undef. π
π§ _parse_response_line
private instance (@) _parse_response_line (String $line)
Description: this method parses the initial response line/header from the server and returns its parts.
and the reason it's its own separate method? so that if we ever decide to get fancy with the response line, we can. future-proofing, we love to see it. π
π§ _clear_errors
private instance () _clear_errors ()
Description: this method clears out any current errors. fresh slate, clean girl aesthetic. π
π§ _filter
private instance (\%) _filter (String $msg, String $command)
Description: makes the actual call to the spamd server for the various filter methods β ie PROCESS, CHECK, HEADERS, etc. the command you pass in is what gets sent to the spamd server.
the return value is a hash reference</> containing several pieces of information, if available:
content_lengthisspamscorethresholdmessage(if available)report(if available)
okay that's the whole page, you ate that, congrats π this was perl v5.40.1, dated 2026-07-23, and it's the Mail::...Client(3pm) page from User Contributed Perl Documentation. go forth and filter some spam, bestie π¦β¨
π¦ where this page comes from
- ubuntu stonking: spamassassin 4.0.2+svn1935691-1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms