about summary refs log tree commit
diff options
context:
space:
mode:
authorDanil Onishchenko <rubber.cthulhu@gmail.com>2015-01-22 17:40:17 +0700
committerDanil Onishchenko <rubber.cthulhu@gmail.com>2015-01-22 17:40:17 +0700
commit7e251383639974ba9558fd20673837d4357194cc (patch)
treed046dd85008602b9036ab0e149fbbff4995db32a
parent8a45b7874b9ebadf653abcd57593758f6632f014 (diff)
downloadperl-libnet-7e251383639974ba9558fd20673837d4357194cc.tar.gz
Optional automatic hello
Added option "SendHello => 0|1" to constructor Net::SMTP::new().
If an option "SendHello" is passed and set to 0 then command HELO will not be sent during calling of constructor Net::SMTP::new() and it has to be sent manually using method Net::SMTP::hello(). If the option isn't passed or set to 1 then the constructor works in the same manner as in earlier versions (command HELO is sent automatically in the constructor). The fact that option is on by default allows to keep compatibility with previous versions of the library. Performing Net::SMTP::hello() manually allows to handle the result of the command in the same way as for other commands.
-rw-r--r--lib/Net/SMTP.pm14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Net/SMTP.pm b/lib/Net/SMTP.pm
index 91b1598..426d50c 100644
--- a/lib/Net/SMTP.pm
+++ b/lib/Net/SMTP.pm
@@ -20,7 +20,7 @@ use Net::Cmd;
 use Net::Config;
 use Socket;
 
-our $VERSION = "3.06";
+our $VERSION = "3.061";
 
 # Code for detecting if we can use SSL
 my $ssl_class = eval {
@@ -112,11 +112,13 @@ sub new {
   (${*$obj}{'net_smtp_banner'}) = $obj->message;
   (${*$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;
+  if( !exists $arg{SendHello} || $arg{SendHello} ) {
+    unless ($obj->hello($arg{Hello} || "")) {
+      my $err = ref($obj) . ": " . $obj->code . " " . $obj->message;
+      $obj->close();
+      $@ = $err;
+      return;
+    }
   }
 
   $obj;