[Mailmunge] Mailmunge::Response syntax
Dianne Skoll
dianne at skollsoft.com
Tue Jul 30 15:31:09 EDT 2024
On Tue, 30 Jul 2024 15:26:08 -0400
list--- via Mailmunge <mailmunge at lists.mailmunge.org> wrote:
> sub filter_recipient {
> Mailmunge::Response->REJECT(...);
> return if $ctx->message_rejected;
> ...
> }
That will *NOT* work. The return value from filter_recipient must
be a Mailmunge::Response object.
> And is there something like $ctx->message_rejected but for knowing if
> Mailmunge::Response->CONTINUE() was used to do something like this?
> sub filter_recipient {
> if ($condition1) {
> Mailmunge::Response->REJECT(...);
> } elseif ($condition2) {
> Mailmunge::Response->CONTINUE();
> }
> if ($ctx->message_rejected || ??? ) {return;}
> ...
> }
None of that will work. You should have "return " before the
Mailmunge::Response objects, in which case you do not need to check
for message_rejected, etc. Like this:
sub filter_recipient {
if ($condition1) {
return Mailmunge::Response->REJECT(...);
}
if ($condition2) {
return Mailmunge::Response->CONTINUE();
}
# ... more things here
# We must ALWAYS return a Mailmunge::Response object, so end with...
return Mailmunge::Response->CONTINUE();
}
If you do not return a Mailmunge::Response object where one is required,
Mailmunge will log an error message and tempfail the mail.
Regards,
Dianne.
More information about the Mailmunge
mailing list