diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-0.96/docs/hooks.md mezzanine_patched_qpsmtpd-0.96/docs/hooks.md --- qpsmtpd-0.96/docs/hooks.md 2016-02-16 23:52:02.000000000 +0100 +++ mezzanine_patched_qpsmtpd-0.96/docs/hooks.md 2016-05-03 21:56:38.216306190 +0200 @@ -343,26 +343,20 @@ The `data_post_headers` hook is called after the client sends the final .\r\n of a message and before the message is processed by `data_post`. This hook is -primarily used by plugins that insert new headers (ex: Received-SPF) and/or +used by plugins that insert new headers (ex: Received-SPF) and/or modify headers such as appending to Authentication-Results (SPF, DKIM, DMARC). When it is desirable to have these header modifications evaluated by filtering software (spamassassin, dspam, etc.) running on `data_post`, this hook should be used instead of `data_post`. -Allowed return codes are - -- DENY - - Return a hard failure code +Note that you cannot reject in this hook, use the data_post hook instead -- DENYSOFT - - Return a soft failure code +Allowed return codes are -- DENY\_DISCONNECT / DENYSOFT\_DISCONNECT +- DECLINED - as above but with disconnect + Do nothing ## hook\_data\_post diff -Nur -x '*.orig' -x '*.rej' qpsmtpd-0.96/plugins/dmarc mezzanine_patched_qpsmtpd-0.96/plugins/dmarc --- qpsmtpd-0.96/plugins/dmarc 2016-02-16 23:52:02.000000000 +0100 +++ mezzanine_patched_qpsmtpd-0.96/plugins/dmarc 2016-05-03 21:57:11.943312651 +0200 @@ -102,6 +102,7 @@ else { $self->{_dmarc} = Mail::DMARC::PurePerl->new(); $self->register_hook('data_post_headers', 'check_dmarc'); + $self->register_hook('data_post', 'reject_dmarc'); }; } @@ -189,6 +190,13 @@ return DECLINED if $self->is_immune; $self->adjust_karma(-3); -# at what point do we reject? - return $self->get_reject("failed DMARC policy"); + # Add a mark now so the data_post hook can do the real reject + $transaction->notes('reject_dmarc', '1'); +} + +sub reject_dmarc { + my ($self, $transaction) = @_; + return $self->get_reject("failed DMARC policy") + if ($transaction->notes('reject_dmarc')); + return DECLINED; }