Hi again,
I confused a bit. The problem is that, LMTP module does not return multiline reply: It returns multiple single-line replys.
Attached patch will fix this bug. Additionally, LMTP replys with 503 to DATA when there are no valid recipients.
Regards,
-- nezumi
On 2015-9月-08 火 01:23:55, NEZUMI wrote:
Show quoted text> Hi,
>
> If Net::Server::Mail::LMTP sets DATA callback, it will be called
> multiple times by each recipient in one LMTP transaction.
>
> This behavior is inconsistent with other modules, SMTP and ESMTP. I
> suppose LMTP module behaves wrong.
>
> I checked Net::Server::Mail::LMTP 0.16 bundled in Net-Server-Mail
> 0.21.
>
>
> Regards,
>
> --- nezumi
--- Net-Server-Mail-0.21/lib/Net/Server/Mail/LMTP.pm.orig 2013-09-05 19:54:19.000000000 +0900
+++ Net-Server-Mail-0.21/lib/Net/Server/Mail/LMTP.pm 2015-09-09 12:41:40.000000000 +0900
@@ -156,12 +156,25 @@
=cut
+sub data {
+ my ( $self, $args ) = @_;
+
+ unless ( ref $self->step_forward_path eq 'ARRAY'
+ and @{ $self->step_forward_path } ) {
+ $self->reply( 503, 'Bad sequence of commands' );
+ return;
+ }
+ $self->SUPER::data( $args );
+}
+
sub data_finished {
my ($self) = @_;
- my $recipients = $self->step_forward_path();
+ my @recipients = @{ $self->step_forward_path || [] };
- foreach my $forward_path (@$recipients) {
+ $self->{continuous_reply} = 1;
+ while ( my $forward_path = shift @recipients ) {
+ $self->{continuous_reply} = 0 unless @recipients;
$self->make_event(
name => 'DATA',
arguments => [ \$self->{_data}, $forward_path ],
@@ -169,6 +182,7 @@
failure_reply => [ 550, "$forward_path Failed" ],
);
}
+ $self->{continuous_reply} = 0;
# reinitiate the connection
$self->step_reverse_path(1);
@@ -178,6 +192,17 @@
return;
}
+sub reply {
+ my ( $self, $code, $msg ) = @_;
+
+ if (not ref $msg and $self->{continuous_reply} ) {
+ my $out = $self->{out};
+ print $out "$code-$msg\r\n";
+ } else {
+ $self->SUPER::reply( $code, $msg );
+ }
+}
+
=pod
=head1 SEE ALSO