Rather than detecting the TO address as missing in the DATA handler,
moved the detection to the RCPT command handler where an error response
can be generated.
return 0;
}
-sub DATA_smtp {
- my $testno;
+sub RCPT_smtp {
+ my ($args) = @_;
- if($smtp_rcpt =~ /^TO:(.*)/) {
- $testno = $1;
+ logmsg "RCPT_smtp got $args\n";
+
+ if($args !~ /^TO:(.*)/) {
+ sendcontrol "501 Unrecognized parameter\r\n";
}
else {
- return; # failure
+ $smtp_rcpt = $1;
+
+ sendcontrol "200 Receivers accepted\r\n";
}
+ return 0;
+}
+
+sub DATA_smtp {
+ my $testno = $smtp_rcpt;
+
$testno =~ s/^([^0-9]*)([0-9]+).*/$2/;
sendcontrol "354 Show me the mail\r\n";
}
-sub RCPT_smtp {
- my ($args) = @_;
-
- logmsg "RCPT_smtp got $args\n";
-
- $smtp_rcpt = $args;
-
- sendcontrol "200 Receivers accepted\r\n";
-
- return 0;
-}
-
sub HELO_smtp {
my ($client) = @_;