From 1cb97b891a46dba5a10de181f51b382c5e810386 Mon Sep 17 00:00:00 2001 From: Graham Barr Date: Sat, 9 Feb 2008 15:04:37 +0000 Subject: Set $@ when -> returns undef --- Net/SMTP.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Net/SMTP.pm b/Net/SMTP.pm index 45a228a..db5907b 100644 --- a/Net/SMTP.pm +++ b/Net/SMTP.pm @@ -59,7 +59,9 @@ sub new { $obj->debug(exists $arg{Debug} ? $arg{Debug} : undef); unless ($obj->response() == CMD_OK) { + my $err = ref($obj) . ": " . $obj->code . " " . $obj->message; $obj->close(); + $@ = $err; return undef; } @@ -70,7 +72,9 @@ sub new { (${*$obj}{'net_smtp_domain'}) = $obj->message =~ /\A\s*(\S+)/; unless ($obj->hello($arg{Hello} || "")) { + my $err = ref($obj) . ": " . $obj->code . " " . $obj->message; $obj->close(); + $@ = $err; return undef; } @@ -597,6 +601,9 @@ known as mailhost: This is the constructor for a new Net::SMTP object. C is the name of the remote host to which an SMTP connection is required. +On failure C will be returned and C<$@> will contain the reason +for the failure. + C is optional. If C is not given then it may instead be passed as the C option described below. If neither is given then the C specified in C will be used. -- cgit v1.2.3-24-ge0c7