[Mailmunge] filter_recipient()

Dianne Skoll dianne at skollsoft.com
Thu Aug 12 10:34:59 EDT 2021


Hi,

Please read the docs carefully.  You can't call any of the action_*
functions outside of a message context.  For
filter_relay/filter_helo/filter_sender/filter_recipient, you must
communicate your intention by returning a Mailmunge::Response object.

> In my situation i do sub-processing in nested functions called from 
> inside of filter_recipient() and would decided to reject a message in 
> one of these sub-functions. So i can't use return 
> Mailmunge::Response->*() in these sub-functions.

Why not?

sub filter_recipient {
    my ($self, $ctx) = @_;

    my $resp = $self->sub_function($ctx);
    return $resp unless $resp->is_success;

    # Further processing here, possibly
    # with more sub-function calls as above
    return $resp;
}

sub sub_function
{
    my ($self, $ctx) = @_;
    if (some_condition()) {
        return Mailmunge::Response->REJECT(msg => 'Go away');
    }
    return Mailmunge::Response->CONTINUE();
}

Regards,

Dianne.


More information about the Mailmunge mailing list