diff --git a/README.plugins b/README.plugins index 60c9d08..a9a64ac 100644 --- a/README.plugins +++ b/README.plugins @@ -159,3 +159,14 @@ hook returned. Returning DONE or OK will stop the next deny hook from being run. DECLINED will make qpsmtpd run the remaining configured deny hooks. +=head1 Return Values and Notes + +Insert stuff here about how: + + - if we're in a transaction, the results of a callback are stored +in + $self->transaction->notes( $code->{name})->{"hook_$hook"}->{return} + + - if we're in a connection, store things in the connection notes instead. + + diff --git a/lib/Qpsmtpd.pm b/lib/Qpsmtpd.pm index ca681c0..bcd9e2e 100644 --- a/lib/Qpsmtpd.pm +++ b/lib/Qpsmtpd.pm @@ -232,6 +232,16 @@ sub run_hooks { ."running the $hook hook returned undef!") and next; + if ($self->transaction) { + my $tnotes = $self->transaction->notes( $code->{name} ); + $tnotes->{"hook_$hook"}->{'return'} = $r[0] + if (!defined $tnotes || ref $tnotes eq "HASH"); + } else { + my $cnotes = $self->connection->notes( $code->{name} ); + $cnotes->{"hook_$hook"}->{'return'} = $r[0] + if (!defined $cnotes || $cnotes eq "HASH"); + } + # should we have a hook for "OK" too? if ($r[0] == DENY or $r[0] == DENYSOFT) { $r[1] = "" if not defined $r[1];