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_length
  • isspam
  • score
  • threshold
  • message
  • report

🫢 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.

⚠️ an undef return value means there was an error β€” check the resp_code / resp_msg values 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_length
  • isspam
  • score
  • threshold
  • message (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