Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Using Email::Stuff to send SMTP mail through GMail

by initself (Monk)
on Sep 19, 2006 at 22:44 UTC ( [id://573821]=note: print w/replies, xml ) Need Help??


in reply to Re: Using Email::Stuff to send SMTP mail through GMail
in thread Using Email::Stuff to send SMTP mail through GMail

I made that change as you suggested but I still get an error message:

Couldn't connect to smtp.gmail.com at testmail.pl line 16.
->send('SMTP', Host => 'smtp.gmail.com', PeerPort => 465, ssl => 1, username => 'mike@mikebaas.com', password => 'x', );

Replies are listed 'Best First'.
Re^3: Using Email::Stuff to send SMTP mail through GMail
by shenme (Priest) on Sep 20, 2006 at 00:33 UTC
    Well I'm not doing any better than you, although being on Win32 may distort things. Got some error messages though...

    I ended up spliting up the call string in order to intervene in the setup steps:

    my $objst = Email::Stuff ->to('tshinnic@io.com') ->from('tshinnic@gmail.com') ->subject('Test Subject') ->text_body('This is a test.'); # This forces Net::SMTP::SSL to be loaded $objst->using( 'SMTP', ssl => 1 ); # Which allows us to do this ... $IO::Socket::SSL::DEBUG = 1; my $rc = $objst->send('SMTP', ssl => 1, Host => 'smtp.gmail.com', PeerPort => 465, username => 'tshinnic', password => 'xxx', Debug => 1, );
    which finally gets us an actual error message!
    CA file certs/my-ca.pem not found, using CA path instead. IO::Socket::INET configuration failederror:00000000:lib(0):func(0):rea +son(0) at C:/Perl587/site/lib/Email/Send/SMTP.pm line 37
    which is of very little help to me, anyway...

    After taking the same extraordinary measures, what error messages do you see?

      Doesn't matter if it is on Win32 or *nix, I could not build Email::Stuff onWin32, so I tried it on one of my CentOS testing servers:
      #!/usr/bin/perl use warnings; use strict; use Email::Stuff; my $objst = Email::Stuff ->to('jophnday@wordsnimages.com') ->from('praecipuus@gmail.com') ->subject('Test Subject') ->text_body('This is a test.'); # This forces Net::SMTP::SSL to be loaded $objst->using( 'SMTP', ssl => 1 ); # Which allows us to do this ... $IO::Socket::SSL::DEBUG = 1; my $rc = $objst->send('SMTP', ssl => 1, Host => 'smtp.gmail.com', PeerPort => 465, username => 'praecipuus', password => 'xx***xx', Debug => 1, );
      Result:
      Name "IO::Socket::SSL::DEBUG" used only once: possible typo at emailst +uff.pl line 13. CA file certs/my-ca.pem not found, using CA path instead. IO::Socket::INET configuration failederror:00000000:lib(0):func(0):rea +son(0) at /usr/lib/perl5/site_perl/5.8.7/Email/Send/SMTP.pm line 37
      jdtoronto
        Same here. Exact same error message. My research has led me nowhere to debug that.
      That is exactly the same error message I get now. Off the top of my head, I have no idea what it means. Off to figure it out!
Re^3: Using Email::Stuff to send SMTP mail through GMail
by jdtoronto (Prior) on Sep 20, 2006 at 16:25 UTC
    Eail::Stuff seems to be something of a wrapper around a whole lot of otehr modules, there's no problemw ith that, so after your last post I thought, well, let's see what Net::SMTP::SSL does with this:
    #!/usr/bin/perl use warnings; use strict; use Net::SMTP::SSL; my $smtp = Net::SMTP::SSL->new( 'smtp.gmail.com', Port => 465, Timeout => 30, Debug => 1, ); print $@;
    produces:
    Net::SMTP::SSL: Bad service ''
    So I think the problem is deeper again, Net::SMTP::SSL is purely a thing wrapper around Net::SMTP to enable it to use IO::SOCKET::SSL instead of IO::SOCKET::INET.

    I don't have time to try more now, but this might give you some more thngs to follow up.

    jdtoronto

      First off, testing the socket connection to smtp.gmail.com:465 works great using IO::Socket::SSL:

      use IO::Socket::SSL; my $client = IO::Socket::SSL->new("smtp.gmail.com:465"); if ($client) { print $client "GET / HTTP/1.0\r\n\r\n"; print <$client>; close $client; } else { warn "I encountered a problem: ", IO::Socket::SSL::errstr(); }

      Result:

      220 mx.gmail.com ESMTP c18sm62410hub

      Then a really simple test with Net::SMTP::SSL yields a bad result:

      use Net::SMTP::SSL; use Data::Dumper; my $smtps = Net::SMTP::SSL->new("smtp.gmail.com", Port => 465); print Dumper($smtps);

      Result:

      $VAR1 = undef;

      What puzzles me is that these are very established modules. I'll report more here when I know more.

      Indeed, Email::Stuff is just a usability wrapper (I wrote it that way intentionally).

      Trouble with IO::Socket::(Anything) on Win32 would not surprise me at all, there's a few dragons there.

      What Perl distribution are you using?

      The first step might be to just write a simple test script that tries to connect via SSL, then immediately drops the connect once established, to GMail's server and see if that works.

      That would isolate the problem to the connectivity layer. If you can get that working, then lets look at Email::Stuff and friends.

      Until then though, I consider the entire Email:: family to be blameless here.

        I am on Linux, Perl 5.8.8.

        I must be missing something. I don't see how your suggestion differs from what I did at the outset. I have a simple test script that tries to connect via SSL. But I don't understand enough about the mechanism in the connectivity layer to troubleshoot what is happening in the interim between my script and their servers.

        I tried to break it down by just using Email::Send::SMTP to send a message:

        #!/usr/bin/perl use warnings; use strict; use Email::Send; my $mailer = Email::Send->new({mailer => 'SMTP'}); $mailer->mailer_args([Host => 'smtp.gmail.com:465', ssl => 1, username => 'mike@mikebaas.com', password => 'xxx']); my $message = "From: mike\@mikebaas.com To: test\@mikebaas.com Subject: testing This is the test message body."; my $result = $mailer->send($message); print "$result\n";

        The value of $result is:

        Couldn't connect to smtp.gmail.com:465

        Not quite sure how to get more detail out of the module.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://573821]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-04-18 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found