PERL Email :: Send :: Gmail无法连接到Windows 7上的Gmail帐户 [英] PERL Email::Send::Gmail Cannot connect to Gmail account on Windows 7

查看:254
本文介绍了PERL Email :: Send :: Gmail无法连接到Windows 7上的Gmail帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 电子邮件::发送: :Gmail 发送电子邮件,但由于某些原因我收到一个错误,不允许我连接。

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.

代码是标准示例:

#!/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 $@;

确切的错误是:

Email::Send::Gmail: error connecting to server smtp.gmail.com 
at C:/Perl/site/lib/Email/Send.pm line 256.

我看过我的Gmail帐号,似乎没有什么可以允许访问的。我在Windows7上,从命令行运行。

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.

任何想法?

谢谢
A

推荐答案

升级依赖关系的时间。

电子邮件:: Gmail ::发送 取决于 Net :: SMTP :: SSL ,这取决于 IO ::插座:: SSL 。解决这种类型问题的第一步是升级模块依赖关系,以防万一出现新问题。

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.

不幸的是,4天前,当你首先介绍了这个问题,我无法通过 IO :: Socket :: SSL 1.986 的测试套件在草莓Perl 5.18.2

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.

幸运的是,从那时起,作者已将模块更新为 IO :: Socket :: SSL 1.988 ,我可以在Windows 7和Linux上完全安装和使用它。目前它引发了重新定义的警告( cpan ticket 95881 ),但在升级此依赖关系后,我可以在Windows上发送Gmail邮件。

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.

注意:您将要创建一个 应用专用密码 此代码,否则Gmail可能会阻止登录,并向您发送可疑登录阻止电子邮件。

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.

这篇关于PERL Email :: Send :: Gmail无法连接到Windows 7上的Gmail帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆