[Mailmunge] Using $ctx globally.

Dianne Skoll dianne at skollsoft.com
Tue Jul 30 18:58:08 EDT 2024


On Tue, 30 Jul 2024 18:40:50 -0400
list--- via Mailmunge <mailmunge at lists.mailmunge.org> wrote:

> Can i map the $ctx object to a global reference?

You could, as long as you remember to set the global one at the
beginning of every callback.  But I think it's better just to pass
$ctx as a parameter rather than using globals.  Setting a global means
that the $ctx object's resources are not freed as soon as they would
otherwise be, unless of course you specifically set the global $ctx to
undef at the end of the callback.

> And in the last thread it was mentioned that the filters need to
> return with a response.

OK.  There are two types of callbacks:

1) Callbacks that happen outside of "message context".  These are:

filter_relay, filter_helo, filter_sender, and filter_recipient.  These
ones cannot call any action_XXX methods and must return a Mailmunge::Response
object.

2) Callbacks that happen in "message contect".  These are all the others
such as filter_begin, filter_message, filter_wrapup, etc.  These
ones can call action_XXX methods if they want, and they can optionally
return a Mailmunge::Response object.  If the *do* return a Mailmunge::Response
object, then the calling code translates that into calling the corresponding
action_XXX method.

So no, you don't need to return anything from filter_message or filter_wrapup
unless you actually want to reject or tempfail a message by returning a
Mailmunge::Response object.

Regards,

Dianne.


More information about the Mailmunge mailing list