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

Discussion in 'Perl Misc' started by Kamil, Sep 21, 2005.

  1. Kamil

    Kamil Guest

    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...
     
    Kamil, Sep 21, 2005
    #1
    1. Advertisements

  2. Kamil

    Eric Bohlman Guest

    "Kamil" <> wrote in news:1127286563.416133.57220
    @g43g2000cwa.googlegroups.com:

    > 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"?
     
    Eric Bohlman, Sep 21, 2005
    #2
    1. Advertisements

  3. Kamil

    Kamil Guest

    Thanks for the suggestion Eric. It works fine now. Dunno how I missed
    that... lack of sleep maybe... Thanks again.
     
    Kamil, Sep 22, 2005
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bivin
    Replies:
    1
    Views:
    873
    venkat
    Jun 27, 2003
  2. Ersin Gençtürk

    sending inline image in email via .net smtp mail

    Ersin Gençtürk, Feb 28, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,131
    bruce barker
    Feb 28, 2005
  3. Replies:
    3
    Views:
    1,318
    Roedy Green
    Jan 24, 2006
  4. Alex Hunsley
    Replies:
    4
    Views:
    4,473
    Tim Williams (gmail)
    Jun 29, 2004
  5. Replies:
    3
    Views:
    1,988
    Cowboy \(Gregory A. Beamer\)
    Sep 30, 2008
  6. Gabriel Dragffy

    Sending email using net/smtp

    Gabriel Dragffy, Aug 17, 2007, in forum: Ruby
    Replies:
    1
    Views:
    164
    Gabriel Dragffy
    Aug 18, 2007
  7. Bob
    Replies:
    5
    Views:
    536
    A. Sinan Unur
    Oct 3, 2005
  8. still just me

    Sending HTML (MIME) email with Net::SMTP ?

    still just me, Jan 10, 2008, in forum: Perl Misc
    Replies:
    3
    Views:
    282
    still just me
    Jan 10, 2008
Loading...