$objst->send( 'SMTP', ssl => 1, Host => $RemoteHost, Port => $RemotePort, Proto => 'tcp', username => $username, password => $password, Debug => 1, Reuse => 1, ); #### # Patch to Net::SMTP BEGIN { use Net::SMTP; no warnings 'redefine'; *Net::SMTP::new = sub { print "In my Net::SMTP::new...\n"; package Net::SMTP; use Net::Config; use Net::Cmd; my $self = shift; my $type = ref($self) || $self; my ($host,%arg); if (@_ % 2) { $host = shift ; %arg = @_; } else { %arg = @_; $host=delete $arg{Host}; } my $hosts = defined $host ? $host : $NetConfig{smtp_hosts}; my $obj; my $h; foreach $h (@{ref($hosts) ? $hosts : [ $hosts ]}) { $obj = $type->SUPER::new(PeerAddr => ($host = $h), PeerPort => $arg{Port} || 'smtp(25)', $arg{LocalAddr} ? ( LocalAddr => $arg{LocalAddr} ) : (), $arg{LocalPort} ? ( LocalPort => $arg{LocalPort} ) : (), Proto => 'tcp', Timeout => defined $arg{Timeout} ? $arg{Timeout} : 120 ); last if $obj; } return undef unless defined $obj; $obj->autoflush(1); $obj->debug(exists $arg{Debug} ? $arg{Debug} : undef); unless ($obj->response() == CMD_OK) { $obj->close(); return undef; } ${*$obj}{'net_smtp_exact_addr'} = $arg{ExactAddresses}; ${*$obj}{'net_smtp_host'} = $host; (${*$obj}{'net_smtp_banner'}) = $obj->message; (${*$obj}{'net_smtp_domain'}) = $obj->message =~ /\A\s*(\S+)/; unless($obj->hello($arg{Hello} || "")) { $obj->close(); return undef; } $obj; } }