Skip to content

Commit

Permalink
DMARC plugin: reject in data_post
Browse files Browse the repository at this point in the history
Followup of #258: we cannot reject a connection during data_post_headers. So add a new hook in data_post to do the real rejection
  • Loading branch information
Daniel Berteaud committed May 2, 2016
1 parent 8649015 commit 6425f8a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions plugins/dmarc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ sub register {
else {
$self->{_dmarc} = Mail::DMARC::PurePerl->new();
$self->register_hook('data_post_headers', 'check_dmarc');
$self->register_hook('data_post', 'reject_dmarc');
};
}

Expand Down Expand Up @@ -189,6 +190,13 @@ sub check_dmarc {
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
$self->connection->notes('reject_dmarc', '1');
}

sub reject_dmarc {
my ($self, $transaction) = @_;
return $self->get_reject("failed DMARC policy")
if ($self->connection->notes('reject_dmarc'));
return DECLINED;
}

0 comments on commit 6425f8a

Please sign in to comment.