【问题标题】:How read Gmail via POP3 with ActivePerl 5.10 on Windows XP?如何在 Windows XP 上使用 ActivePerl 5.10 通过 POP3 阅读 Gmail?
【发布时间】:2013-03-15 05:37:07
【问题描述】:

我正在使用带有 ActiveState Perl 5.10.0 的 Windows XP SP3,并且我编写了这个函数——从 CPAN 的 Net::POP3 获取/编辑——试图通过 POP3 读取 Gmail:

  my $pop = Net::POP3->new('pop.gmail.com', 
                            Timeout => 60, 
                            Port => 995, 
                            Debug => 1) || die "$!";
  my $num = $pop->login('xyz@gmail.com', 'password');
  if (!defined($num))
  {
    die "Error: couldn't sign-in to your email account.\n";
  }
  elsif ($num > 0)
  {
    warn "There are $num message(s) in your inbox.\n";
    my $msgnums = $pop->list;
    foreach my $msgnum (keys %$msgnums)
    {
      my $msg = $pop->get($msgnum);
      print @$msg;
    }
  }
  else
  {
    die "There are no messages in your inbox. (Nothing to do.)\n"
  }

  $pop->quit;

代码只是超时并显示此错误消息:

Use of uninitialized value in numeric eq (==) at C:/Perl/lib/Net/POP3.pm line 59.
Bad file descriptor at pop3.pl line xxx (i.e., the Net::POP3->new() line)

在超时发生之前来自 Net::POP3 的调试信息是:

Net::POP3>>> Net::POP3(2.29)
Net::POP3>>>   Net::Cmd(2.29)
Net::POP3>>>     Exporter(5.62)
Net::POP3>>>   IO::Socket::INET(1.31)
Net::POP3>>>     IO::Socket(1.30_01)
Net::POP3>>>       IO::Handle(1.27)
Net::POP3=GLOB(0x20d253c): Timeout at pop3.pl line xxx

我也尝试过使用Mail::POP3Client;在 Windows XP 上没有乐趣,因为 CPAN 和 PPM 都不会安装它及其依赖项(IO::SOCKET::SSL 等)。

知道我的代码有什么问题和/或如何在 Windows XP 上使用 ActivePerl 5.10.0 通过 POP3 读取 Gmail?

根据Gmail,标准配置说明是:

Incoming Mail (POP3) Server - requires SSL:  pop.gmail.com
Use SSL: Yes
Port: 995

【问题讨论】:

  • "Bad file descriptor" 是$! 的常用值,我看到的任何内容都没有让我认为$! 在那里有意义。它的一个基类将消息存储在$@ 中,因此这实际上可能是有意义的。
  • 也就是说,Net::POP3 的使用是行不通的,因为需要 SSL。
  • Re: SSL: 我也试过 Net::POP3::SSLWrapper 但是,像 Mail::POP3Client 等,它不会安装(cpan 和 ppm 都没有)。
  • IO::Socket::SSL 在 ppm 中不可用,因为必须先安装随机数生成器。请参阅其自述文件。奇怪的是,我已经安装了。我认为它实际上可能与 ActivePerl 本身捆绑在一起。 (不过是较新的版本)
  • 当 IO::Socket::SSL 的安装程序指示您阅读其 README 文件并告诉您安装随机数生成器时,您做了什么?

标签: perl email windows-xp gmail pop3


【解决方案1】:

您需要使用 SSL 访问 GMail。这意味着您需要安装 Perl 模块IO::Socket::SSL。但这很简单。 ActiveState 提供了一个很好的 cpan 客户端和大量的二进制“PPM”包。它确实需要您将 Perl 升级到 5.14 或 5.16 或获得支持旧 perls 所需的某种合同。

您也可以使用Strawberry Perl;它有一个同样出色的 cpan 客户端 + 构建工具。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-02
    • 2010-09-27
    • 1970-01-01
    • 1970-01-01
    • 2011-05-27
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多