From 6f70ad0c06dd345c397a7a650baf686e374e5a9f Mon Sep 17 00:00:00 2001 From: Graham Barr Date: Tue, 20 May 2003 11:45:59 +0000 Subject: Net::SMTP - Allow multiple hosts to be passed to new() as an array reference --- Net/SMTP.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Net/SMTP.pm b/Net/SMTP.pm index 1609ac8..be64037 100644 --- a/Net/SMTP.pm +++ b/Net/SMTP.pm @@ -16,7 +16,7 @@ use IO::Socket; use Net::Cmd; use Net::Config; -$VERSION = "2.26"; # $Id: //depot/libnet/Net/SMTP.pm#30 $ +$VERSION = "2.26"; # $Id: //depot/libnet/Net/SMTP.pm#31 $ @ISA = qw(Net::Cmd IO::Socket::INET); @@ -26,11 +26,11 @@ sub new my $type = ref($self) || $self; my $host = shift if @_ % 2; my %arg = @_; - my $hosts = defined $host ? [ $host ] : $NetConfig{smtp_hosts}; + my $hosts = defined $host ? $host : $NetConfig{smtp_hosts}; my $obj; my $h; - foreach $h (@{$hosts}) + foreach $h (@{ref($hosts) ? $hosts : [ $hosts ]}) { $obj = $type->SUPER::new(PeerAddr => ($host = $h), PeerPort => $arg{Port} || 'smtp(25)', @@ -570,6 +570,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. +If C is an array reference then each value will be attempted +in turn until a connection is made. + If C is not given, then the C specified in C will be used. @@ -762,6 +765,6 @@ it under the same terms as Perl itself. =for html
-I<$Id: //depot/libnet/Net/SMTP.pm#30 $> +I<$Id: //depot/libnet/Net/SMTP.pm#31 $> =cut -- cgit v1.2.3-24-ge0c7