Products Resources Support About Us

Perl 5.22.0 Net::SMTP function hangs at dataend()

Running perl 5.22.0 on z/OS 2.2 RSU1605. The SMTP mail function does not complete at dataend(); appears to hang and no mail is sent.

Works correctly using perl 5.8.7 from IBM Ported Tools. Fails on perl 5.16.2 as well.

Basically using this sample program provided in the SMTP file to recreate the failure:

#!/usr/local/bin/perl -w

use Net::SMTP;

$smtp = Net::SMTP->new(‘mailhost’);

if ($smtp->to(‘postmaster’)) {
$smtp->datasend(“To: postmaster\n”);
$smtp->datasend(“A simple test message\n”);
} else {
print "Error: ", $smtp->message();


We change “mailhost” to our smtp mail server and “postmaster” to "" so mail comes to tester. Also the replaced #!/usr/local/bin/perl -w
#!/shared/RSPTz/ported/perl522/bin/perl -w

After failure reproduced, I replaced
$smtp = Net::SMTP->new(‘mailhost’);
$smtp = Net::SMTP->new(‘mailhost’, Debug => 1,);

This change allowed me to determine that all works until the program gets to the dataend() statement.

Greetings, Ed. Thank you for the report. We are looking into the problem, but it will be several days before we will have a response for you.

It’s been months. Any work being done on Perl?

Still looking for some response to my report of Perl 5.22 and SMTP hang.

I’m really sorry this has lingered this long.

I have been able to reproduce the behavior you observed: the script works with perl 5.8.7 from IBM Ported Tools, does not work with the latest version of perl. I’ll be opening an internal bug report for this. I can’t give you an ETA for a fix, though.

– Jerry

Very much appreciate the confirmation that it’s a reproducible problem. Look forward to a resolution.

I landed here through a google search for the same issue after scouring for too long… I ended up doing a somewhat hacky workaround with gmail. Instead of sending:




Gmail will then return a 250 OK for data, and close the connection right after with a 221:

Net::SMTP::_SSL=GLOB(0x5608b7ee1270)<<< 250 2.0.0 OK  1594234698 cq7sm276535edb.66 - gsmtp
Net::SMTP::_SSL=GLOB(0x5608b7ee1270)>>> QUIT
Net::SMTP::_SSL=GLOB(0x5608b7ee1270)<<< 221 2.0.0 closing connection cq7sm276535edb.66 - gsmtp