I try to use Email::Send::Gmailto send email, but for some reason I get an error that it does not allow me to connect.
The code is a standard example:
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:
Email::Send::Gmail: error connecting to server smtp.gmail.com
at C:/Perl/site/lib/Email/Send.pm line 256.
I looked through my gmail account and there seems to be nothing to "allow access". I work in Windows7 and run from the command line.
Any ideas?
Thanks, A
source
share