According to the documentation, on failure new returns undef and $@ contains an appropriate error message. This seems to work as advertised for me:
19:50 >perl -MNet::SMTP -wE "my $smtp = Net::SMTP->new('invalid'); say + 'Next'; if (defined $smtp) { say 'SMTP defined' } else { say 'SMTP u +ndefined'; say $@; } say 'Still alive';" Next SMTP undefined Net::SMTP: Bad hostname 'invalid' Still alive 19:50 >p5u v Net::SMTP Net::SMTP C:\Perl\Strawberry\strawberry-perl-5.20.0.1-64bit-PDL\perl\lib +\Net\SMTP.pm: 2.33 19:50 >
Are you using an old version of the module? Are you sure it’s Net::SMTP->new() that’s causing the crash? Please give a minimal but self-contained script demonstrating the problem, together with the exact error message(s) that result.
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Net::SMTP halts script
by Athanasius
in thread Net::SMTP halts script
by nperrins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |