Hi, I would like to report two bugs (or what seems to me like bugs) in the Net::SMTP module. The first is regarding sending mail with empty content. For example: use Net::SMTP; $s = Net::SMTP->new('localhost', Debug => 1); $s->mail('root'); $s->to('root'); $s->data; $s->datasend(''); $s->dataend; $s->quit; This is the (numbered) output: 1: 2: Net::SMTP: Net::SMTP(2.15) 3: Net::SMTP: Net::Cmd(2.18) 4: Net::SMTP: Exporter 5: Net::SMTP: IO::Socket::INET 6: Net::SMTP: IO::Socket(1.1603) 7: Net::SMTP: IO::Handle(1.1505) 8: 9: Net::SMTP=GLOB(0x81e40c8)<<< 220 gandalf.middle.earth ESMTP Postfix 10: Net::SMTP=GLOB(0x81e40c8)>>> EHLO gandalf.middle.earth 11: Net::SMTP=GLOB(0x81e40c8)<<< 250-gandalf.middle.earth 12: Net::SMTP=GLOB(0x81e40c8)<<< 250-PIPELINING 13: Net::SMTP=GLOB(0x81e40c8)<<< 250-SIZE 10240000 14: Net::SMTP=GLOB(0x81e40c8)<<< 250-ETRN 15: Net::SMTP=GLOB(0x81e40c8)<<< 250 8BITMIME 16: Net::SMTP=GLOB(0x81e40c8)>>> MAIL FROM: 17: Net::SMTP=GLOB(0x81e40c8)<<< 250 Ok 18: Net::SMTP=GLOB(0x81e40c8)>>> RCPT TO: 19: Net::SMTP=GLOB(0x81e40c8)<<< 250 Ok 20: Net::SMTP=GLOB(0x81e40c8)>>> DATA 21: Net::SMTP=GLOB(0x81e40c8)<<< 354 End data with . 22: Net::SMTP=GLOB(0x81e40c8)>>> QUIT 23: Net::SMTP=GLOB(0x81e40c8): Timeout at try line 8 Note line 20-23. What happended here is that datasend() is given a parameter '' of length 0. Consequently, it return 1 unless length($line); and so ${*cmd}{'net_cmd_lastch'} remains non-existent. The subsequent call to dataend() does not work as expected because it return 1 unless(exists ${*$cmd}{'net_cmd_lastch'}); I believe the solution is to return ${*$cmd}{'net_cmd_lastch'} = '', 1 unless length($line); in datasend(). WARNING: This may break command() - I am not sure. But it does solve the afore-mentioned problem. ==== The 2nd bug is with message(). Consider use Net::SMTP; $| = 1; $s = Net::SMTP->new('localhost', Debug => 1); $s->mail('root'); print " ", $s->code, " ", $s->message; $s->to('root'); print " ", $s->code, " ", $s->message; $s->data; print " ", $s->code, " ", $s->message; $s->datasend('some text'); print " ", $s->code, " ", $s->message; $s->dataend; print " ", $s->code, " ", $s->message; $s->quit; print " ", $s->code, " ", $s->message; The numbered output is below: 1: 2: Net::SMTP: Net::SMTP(2.15) 3: Net::SMTP: Net::Cmd(2.18) 4: Net::SMTP: Exporter 5: Net::SMTP: IO::Socket::INET 6: Net::SMTP: IO::Socket(1.1603) 7: Net::SMTP: IO::Handle(1.1505) 8: 9: Net::SMTP=GLOB(0x81e5cb8)<<< 220 gandalf.middle.earth ESMTP Postfix 10: Net::SMTP=GLOB(0x81e5cb8)>>> EHLO gandalf.middle.earth 11: Net::SMTP=GLOB(0x81e5cb8)<<< 250-gandalf.middle.earth 12: Net::SMTP=GLOB(0x81e5cb8)<<< 250-PIPELINING 13: Net::SMTP=GLOB(0x81e5cb8)<<< 250-SIZE 10240000 14: Net::SMTP=GLOB(0x81e5cb8)<<< 250-ETRN 15: Net::SMTP=GLOB(0x81e5cb8)<<< 250 8BITMIME 16: Net::SMTP=GLOB(0x81e5cb8)>>> MAIL FROM: 17: Net::SMTP=GLOB(0x81e5cb8)<<< 250 Ok 18: 250 Ok 19: Net::SMTP=GLOB(0x81e5cb8)>>> RCPT TO: 20: Net::SMTP=GLOB(0x81e5cb8)<<< 250 Ok 21: 250 Ok 22: Net::SMTP=GLOB(0x81e5cb8)>>> DATA 23: Net::SMTP=GLOB(0x81e5cb8)<<< 354 End data with . 24: 354 End data with . 25: Net::SMTP=GLOB(0x81e5cb8)>>> some text 26: 354 End data with . 27: 28: Net::SMTP=GLOB(0x81e5cb8)>>> . 29: Net::SMTP=GLOB(0x81e5cb8)<<< 250 Ok: queued as 177EE3997 30: 250 End data with . 31: Ok: queued as 177EE3997 32: Net::SMTP=GLOB(0x81e5cb8)>>> QUIT 33: Net::SMTP=GLOB(0x81e5cb8)<<< 221 Bye 34: 221 Bye Note line 30-31. It should be "250 Ok: ..."; clearly some buffer is not being cleared. I found that this problem is in dataend() not clearing ${*$cmd}{'net_cmd_resp'} before calling response(). The solution is of course to clear it. :) The promised patch: (I renamed the old module to Cmd.pm.old) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- Cmd.pm.old Mon May 22 13:44:25 2000 +++ Cmd.pm Mon May 22 14:34:09 2000 @@ -345,7 +345,7 @@ return 0 unless defined(fileno($cmd)); - return 1 + return ${*$cmd}{'net_cmd_lastch'} = '', 1 unless length($line); if($cmd->debug) @@ -422,6 +422,7 @@ delete ${*$cmd}{'net_cmd_lastch'}; + ${*$cmd}{'net_cmd_resp'} = []; $cmd->response() == CMD_OK; }