Mailmun...::Rspamd(3)

πŸ“¦ version 3.20, in alpine 3.24

πŸ’– NAME πŸ’–

Okay bestie, welcome to the Mailmun...::Rspamd(3) page from the User Contributed Perl Documentation crew. The module is Mailmunge::Test::Rspamd, and its whole job is: run a message through rspamd. Literally what it says. πŸ’…

✨ ABSTRACT ✨

This class connects to an rspamd daemon at https://www.rspamd.com/ and passes the input message to rspamd for evaluation. That's the vibe check: hand your message over and let rspamd judge it. πŸ¦‹

πŸ¦‹ SYNOPSIS πŸ¦‹

Here's the exact little group-chat script, no cap:

package MyFilter;
use Mailmunge::Test::Rspamd;

sub filter_begin {
    my ($self, $ctx) = @_;
    my $test = Mailmunge::Test::Rspamd->new($self);
    my $ans = $test->rspamd_check($ctx, '127.0.0.1', 11333);
    my $resp = $ans->{response};
    if (!$ans->{results}) {
        # Failure of some kind - timeout, rspamd not running, etc.
        # Specific error message will be in $ans->{response}->message
        return $self->action_tempfail($ctx, $resp->message);
    }

    # We have rspamd results; you can inspect $ans->{results}
    # to decide what action to take, or use the code below to take
    # action based on $ans->{response}; $ans->{response} is a
    # Mailmunge::Response object with a suggested response

    if ($ctx->action_from_response($resp)) {
        # Rspamd suggested an action, which we took
        return;
    }

    # Must be: $resp->is_success so continue with rest of filter
}

🧚 CLASS METHODS 🧚

πŸŽ€ Mailmunge::Test::Rspamd->new($filter) πŸŽ€

Constructs a new Mailmunge::Test::Rspamd object and stores a copy of $filter in it. Iconic constructor behavior, honestly. ✨

🌸 INSTANCE METHODS 🌸

πŸ’… rspamd_check($ctx, $host, $port [, $timeout]) πŸ’…

Connects to the rspamd daemon on the given $host and $port and asks it to evaluate the current message. The $timeout is an overall timeout in seconds for rspamd to reply; if you don't supply it, it defaults to 300 seconds. So yes, bestie, there's a built-in patience window. ⏳

The return value from rspamd_check is a hash with the following elements:

πŸ’– response πŸ’–

A Mailmunge::Response object with the suggested response to the message. If something went wrong with rspamd, then the response element will be the only element in the hash. Its status will be set to TEMPFAIL, and its message will contain an error message. 😭

🌈 results 🌈

If rspamd successfully scanned the message, the results element will be a hash containing the rspamd response. This data structure is described in detail at https://www.rspamd.com/doc/architecture/protocol.html#rspamd-http-reply. It is up to the caller of rspamd_check to inspect the reply from rspamd and call appropriate functions such as action_reject, etc. You're the main character here β€” rspamd gives you the info, you decide the action. πŸ‘‘

If rspamd did not successfully scan the message, then there will be no results element. Fr fr, that key just won't exist.

Vibe check: if results is missing, the response key is your only key, and it's giving TEMPFAIL energy. 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

πŸŽ€ AUTHOR πŸŽ€

Dianne Skoll dianne@skollsoft.com β€” thank you, queen. 🌸

πŸ’œ LICENSE πŸ’œ

This code is licensed under the terms of the GNU General Public License, version 2. Periodt. πŸ“œ


Cute sign-off time: this page is rockin' perl v5.42.2, dated 2025-10-05, and its manual name is Mailmun...::Rspamd(3). Byeee bestie, go scan some messages! πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from