Perl Net :: IMAP :: Client无法连接到raspi上的imap-server(伸展灯)

时间:2019-06-20 07:53:38

标签: perl imap

使用Net :: IMAP :: Client连接电子邮件帐户的脚本可在Windows上使用,但不能在raspi上连接。

我在Windows上开发了脚本,并且效果很好。当我尝试在raspi(Raspbian Stretch Light 04/2019)上运行它时,它无法连接到服务器(imap.gmx.de)。我已经安装了openssl和libssl-dev。必须运行libssl-dev才能运行Net :: IMAP :: Client所需的模块Net :: SSLeay。

我可以使用shell命令openssl从raspi连接到此imap服务器。我可以连接,登录,浏览文件夹...因此,我认为openssl的实现和网络配置都可以。但这不适用于脚本。

#!/usr/bin/perl
use Net::IMAP::Client;

print "user: ";
my $user=<STDIN>;
chomp ($user);
print "password: ";
my $password=<STDIN>;
chomp($password);

my $imap = Net::IMAP::Client->new(

    server => 'imap.gmx.de',
    user   => $user,
    pass   => $password,
    ssl    => 1,                              # (use SSL? default no)
#    ssl_verify_peer => 1,                     # (use ca to verify server, default yes)
#   ssl_ca_file => '/etc/ssl/certs/certa.pm', # (CA file used for verify server) or
#   ssl_ca_path => '/etc/ssl/certs/',         # (CA path used for SSL)
    port   => 993                             # (but defaults are sane)

) or die "Could not connect to IMAP server";

$imap->login or
  die('Login failed: ' . $imap->last_error);

在raspi上,我总是收到消息

Could not connect to IMAP server at client.pl line 11, <STDIN> line 2.

对于die "Could not connect to IMAP server: $@";,错误消息为

Could not connect to IMAP server: Can't call method "opened" on an undefined value at /usr/local/share/perl/5.24.1/Net/IMAP/Client.pm line 53, <STDIN> line 2.

0 个答案:

没有答案