diff --git a/README.plugins b/README.plugins index 986ee15..e09b3cd 100644 --- a/README.plugins +++ b/README.plugins @@ -85,3 +85,11 @@ Allowed return codes: All other codes will qpsmtpd do the default response. + +=head2 disconnect + +Called just before we shutdown a connection. + +The return code is ignored. If a plugin returns anything but DECLINED +the following plugins will not be run (like with all other hooks). + diff --git a/lib/Qpsmtpd.pm b/lib/Qpsmtpd.pm index 89980f5..bbb9153 100644 --- a/lib/Qpsmtpd.pm +++ b/lib/Qpsmtpd.pm @@ -273,7 +273,12 @@ sub quit { if ($rc != DONE) { $self->respond(221, $self->config('me') . " closing connection. Have a wonderful day."); } - exit; + $self->disconnect(); +} + +sub disconnect { + my $self = shift; + $self->run_hooks("disconnect"); } sub data { diff --git a/lib/Qpsmtpd/TcpServer.pm b/lib/Qpsmtpd/TcpServer.pm index 970babc..72e27df 100644 --- a/lib/Qpsmtpd/TcpServer.pm +++ b/lib/Qpsmtpd/TcpServer.pm @@ -52,5 +52,10 @@ sub respond { return 1; } +sub disconnect { + my $self = shift; + $self->SUPER::disconnect(@_); + exit; +} 1;