Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Problems with Email::Send::Gmail

by agnome (Initiate)
on Jun 17, 2015 at 18:45 UTC ( [id://1130856]=perlquestion: print w/replies, xml ) Need Help??

agnome has asked for the wisdom of the Perl Monks concerning the following question:

I'm having problems with Email::Send::Gmail. I'm using the example code on CPAN which I reproduced below and it all works fine on my local Windows machine. However, on my remote AWS server I just get the 'Email::Send::Gmail: error connecting to server smtp.gmail.com' error message and I can't seem to work out what the problem is.

#!/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 => 'myemail@gmail.com', To => 'recipient@gmail.com', Subject => 'Subject', ], body => 'Hello World!', ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => 'myemail@gmail.com', password => 'password', ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@;

Looking through the code, the error message is generated by this bit of code in Email/Send/Gmail.pm:

# mostly cribbed from Email::Send::SMTP sub send { my ( $class, $message, @args ) = @_; my %args = @args; my ( $username, $password ) = @args{qw[username password]}; my $smtp = Net::SMTP::SSL->new( 'smtp.gmail.com', Port => 465, Debug => 0, ) || croak( 'Email::Send::Gmail: error connecting to server smtp.gmail.com +'); ...

Any suggestions would be most gratefully received

Replies are listed 'Best First'.
Re: Problems with Email::Send::Gmail
by hippo (Bishop) on Jun 17, 2015 at 22:00 UTC

    Some guesses:

    1. Different CA cert bundles between windows box and AWS.
    2. Connection disallowed by AWS policy.
    3. Connection disallowed by Gmail policy.
    4. Different versions of perl between windows box and AWS.
    5. Different versions of the modules between windows box and AWS.
    6. Different versions of openssl between windows box and AWS.

    Personally I would try to make the connection by hand, outside of perl using openssl's handy s_client command. If that fails then you know it's nothing to do with perl.

Re: Problems with Email::Send::Gmail
by tonto (Friar) on Jun 17, 2015 at 22:30 UTC

    I tried to use Email::Send::Gmail too, and also failed. The error I got is "not a GLOB reference at ... SSL.pm line 16".

    I was somewhat more successful using Email::Send, but the email was rejected by Google's policies, as hippo suggested. Google will allow you to lower your security settings to allow the device to connect but they warn that it is not a good idea.

    Correction: it was Email::Send::SMTP::TLS, which uses Email::Send, the documentation shows how to use Gmail.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-03-28 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found