sending email with Net::SMTP::SSL -- help needed

K

Kamil

Hi, I am new to perl, and dont know much about CPAN and modules... What
am I doing wrong in the Net::SMTP::SSL constructor?!

This works fine:

my $smtp_port=465;
my $smtp = Net::SMTP::SSL->new(Host => "smtp.gmail.com", Port =>
$smtp_port);
die "Couldn't connect to server" unless $smtp;


But, this does NOT work:

my $smtp_port=465;
my $smtp_server="smtp.google.com";
my $smtp = Net::SMTP::SSL->new(Host => $smtp_server, Port =>
$smtp_port);
die "Couldn't connect to server" unless $smtp;


Error:

Couldn't connect to server at ./process_sweep.pl line 1298.


The documentation says:

Host - SMTP host to connect to. It may be a single scalar, as defined
for the PeerAddr option in IO::Socket::INET, or a reference to an array
with hosts to try in turn. The "host" method will return the value
which was used to connect to the host.


I have tried using:

my $smtp_port=465;
my @smtp_server;
push(@smtp_server,"smtp.google.com");
my $smtp = Net::SMTP::SSL->new(Host => \@smtp_server, Port =>
$smtp_port);
die "Couldn't connect to server" unless $smtp;


But it doesn't work either...
 
E

Eric Bohlman

Hi, I am new to perl, and dont know much about CPAN and modules... What
am I doing wrong in the Net::SMTP::SSL constructor?!

This works fine:

my $smtp_port=465;
my $smtp = Net::SMTP::SSL->new(Host => "smtp.gmail.com", Port =>
$smtp_port);
die "Couldn't connect to server" unless $smtp;


But, this does NOT work:

my $smtp_port=465;
my $smtp_server="smtp.google.com";
my $smtp = Net::SMTP::SSL->new(Host => $smtp_server, Port =>
$smtp_port);
die "Couldn't connect to server" unless $smtp;


Error:

Couldn't connect to server at ./process_sweep.pl line 1298.

The most obvious thing I see is that you're trying to connect to two
different SMTP servers. Does your first attempt work if you substitute
"smtp.google.com" for "smtp.gmail.com"?
 
K

Kamil

Thanks for the suggestion Eric. It works fine now. Dunno how I missed
that... lack of sleep maybe... Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top