PERL Email::Send::Gmail Cannot connect to Gmail account on Windows 7

email, perl

Solution

Time to upgrade your dependencies.

`Email::Gmail::Send` depends on `Net::SMTP::SSL` which depends on `IO::Socket::SSL`. The first step I take to solving this type of problem is to upgrade the module dependencies just in case a new issue has already been addressed.

Unfortunately, 4 Days ago when you first introduced this problem, I was unable to pass the test suite for `IO::Socket::SSL 1.986` on `Strawberry Perl 5.18.2`.

t/public_suffix_lib_uri.t ......... ok
failed to connect: An operation was attempted on something that is not a socket. at t/public_suffix_ssl.t line 87.
# Looks like you planned 24 tests but ran 2.
# Looks like your test exited with 10038 just after 2.

Fortunately, since then the author has updated the module to `IO::Socket::SSL 1.988`, and I'm able to fully install and use it on both Windows 7 and Linux. Currently it throws redefined warnings (`cpan ticket 95881`), but I was able to send Gmail messages on Windows after upgrading this dependency.

Note: You'll want to create an `application specific password` for this code, otherwise Gmail might block the login and send you a "Suspicious sign in prevented" email.

Problem

I am trying to use `Email::Send::Gmail` to send an email, but for some reason I am getting an error that it is not allowing me to connect. The code is the standard example: ``` #!/usr/bin/perl use strict; use warnings; use Email::Send; use Email::Send::Gmail; use Email::Simple::Creator; my $email = Email::Simple->create( header => [ From => 'myaddress@gmail.com', To => 'myaddress@gmail.com', Subject => 'Server down', ], body => 'The server is down. Start panicing.', ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => 'myaddress@gmail.com', password => 'XXXX', ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@; ``` Exact Error is: ``` Email::Send::Gmail: error connecting to server smtp.gmail.com at C:/Perl/site/lib/Email/Send.pm line 256. ``` I've looked around my gmail account and there doesn't seem to be anything there to "allow access". I'm on Windows7 and running from the command line. Any ideas? Thanks, A

Original source