This is not a question but a deposit in the archive to let others know how to get at the error message when Net::SMTP->new() returns undef, as in ...

# Assuming 'blargh' is an unreachable host. perl -MNet::SMTP -e '$m = Net::SMTP->new( "blargh" ); $m->mail( $EVN{U +SER} )' # produces "Can't call method "mail" on an undefined value at ...".

I would have thought that if Net::SMTP->new() fails, then the error message could have been retrived via $!, more so as the module pod (version 2.31, perl 5.8.8) does not mention anything on the topic. But $! produces odd error message ...

Net::SMTP->new( 'blargh' ) or die $!; # produces "Invalid argument at -e line 1".

... try the same with $@ or without $!, more reasonable message is produced ...

Net::SMTP->new( 'blargh' ) #or die or die $@ ; # produces "Net::SMTP: Bad hostname 'blargh' at -e line 1.".

... apparently object construction is being trapped somewhere.

I see IO::Socket::INET -- only beacuse I peeked inside Net::SMTP source -- pod on new method mentions $@ but only indirectly in an example. There is no formal mention of how to get the reason for a socket connection failure.