From 5b74b9c1d38ddbd91e0bc4132e4731a723909cec Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 27 Mar 2013 18:16:43 -0400 Subject: [PATCH] Q:Plugin.pm: abstracted out store_deferred_reject --- lib/Qpsmtpd/Plugin.pm | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/Qpsmtpd/Plugin.pm b/lib/Qpsmtpd/Plugin.pm index 6d8e1c1..83ae43b 100644 --- a/lib/Qpsmtpd/Plugin.pm +++ b/lib/Qpsmtpd/Plugin.pm @@ -225,13 +225,7 @@ sub get_reject { # the naughty plugin will reject later if ( $reject eq 'naughty' ) { $self->log(LOGINFO, "fail, NAUGHTY" . $log_mess); - if ( ! $self->connection->notes('naughty') ) { - $self->connection->notes('naughty', $smtp_mess); - }; - if ( ! $self->connection->notes('naughty_reject_type') ) { - $self->connection->notes('naughty_reject_type', $self->{_args}{reject_type} ); - } - return (DECLINED); + return $self->store_deferred_reject( $smtp_mess ); }; # they asked for reject, we give them reject @@ -251,6 +245,24 @@ sub get_reject_type { : $default; }; +sub store_deferred_reject { + my ($self, $smtp_mess) = @_; + + # store the reject message that the naughty plugin will return later + if ( ! $self->connection->notes('naughty') ) { + $self->connection->notes('naughty', $smtp_mess); + } + else { + # append this reject message to the message + my $prev = $self->connection->notes('naughty'); + $self->connection->notes('naughty', "$prev\015\012$smtp_mess"); + }; + if ( ! $self->connection->notes('naughty_reject_type') ) { + $self->connection->notes('naughty_reject_type', $self->{_args}{reject_type} ); + } + return (DECLINED); +}; + sub is_immune { my $self = shift;