diff options
-rw-r--r-- | Net/SMTP.pm | 7 |
1 files changed, 7 insertions, 0 deletions
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<HOST> is the name of the remote host to which an SMTP connection is required. +On failure C<undef> will be returned and C<$@> will contain the reason +for the failure. + C<HOST> is optional. If C<HOST> is not given then it may instead be passed as the C<Host> option described below. If neither is given then the C<SMTP_Hosts> specified in C<Net::Config> will be used. |