Add a hook for the DATA command

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@269 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2004-07-16 07:27:26 +00:00
parent de9a7fa02a
commit c60710e871
2 changed files with 30 additions and 2 deletions

View File

@ -2,7 +2,7 @@ package Qpsmtpd::Plugin;
use strict;
my %hooks = map { $_ => 1 } qw(
config queue data_post quit rcpt mail ehlo helo
config queue data data_post quit rcpt mail ehlo helo
auth auth-plain auth-login auth-cram-md5
connect reset_transaction unrecognized_command disconnect
);

View File

@ -365,7 +365,35 @@ sub data {
my $self = shift;
$self->respond(503, "MAIL first"), return 1 unless $self->transaction->sender;
$self->respond(503, "RCPT first"), return 1 unless $self->transaction->recipients;
$self->respond(354, "go ahead");
my ($rc, $msg) = $self->run_hooks("data");
if ($rc == DONE) {
return 1;
}
elsif ($rc == DENY) {
$self->respond(554, $msg || "Message denied");
$self->reset_transaction();
return 1;
}
elsif ($rc == DENYSOFT) {
$self->respond(451, $msg || "Message denied temporarily");
$self->reset_transaction();
return 1;
}
elsif ($rc == DENY_DISCONNECT) {
$self->respond(554, $msg || "Message denied");
$self->disconnect;
return 1;
}
elsif ($rc == DENYSOFT_DISCONNECT) {
$self->respond(451, $msg || "Message denied temporarily");
$self->disconnect;
return 1;
}
else {
$self->respond(354, "go ahead");
}
my $buffer = '';
my $size = 0;
my $i = 0;