about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>2008-02-09 15:04:37 +0000
committerGraham Barr <gbarr@pobox.com>2009-02-24 10:40:49 -0600
commit1cb97b891a46dba5a10de181f51b382c5e810386 (patch)
treec0052aaa6785154f3a8a9006a242fb820e5d3306
parent4f63fb1d340c21be01969ebcd4249f77507f8626 (diff)
downloadperl-libnet-1cb97b891a46dba5a10de181f51b382c5e810386.tar.gz
Set $@ when -> returns undef
-rw-r--r--Net/SMTP.pm7
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.