这个Mail::IMAPClient->new()
冻结在Windows 7中:
sub connectGMail
{
my $client = Mail::IMAPClient->new
(
Server => 'imap.gmail.com',
Port => 993,
Ssl => 1,
User => 'whateverUser',
Password => 'aG00dP455w0rd',
Socket => IO::Socket::SSL->new
(
SSL_verify_mode => SSL_VERIFY_NONE
)
)
or die "Cannot connect ($@)\n";
return $client;
}
我尝试停用Windows防火墙,但没有任何改变。
一个非常相似的代码在Linux中运行良好:
sub connectGMail
{
my $client = Mail::IMAPClient->new
(
Server => 'imap.gmail.com',
Port => 993,
Ssl => 1,
User => 'whateverUser',
Password => 'aG00dP455w0rd'
)
or die "Cannot connect ($@)\n";
return $client;
}
在这两种情况下,Mail::IMAPClient
从CPAN存储库安装得很好,但在Windows中,如果我不包含套接字选项,它会向我显示此警告
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
together with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
并且脚本的其余部分(解析电子邮件)将无法正常工作。
error: unexpected end of header
error: unexpected end of header
error: unexpected end of header
任何帮助将不胜感激,提前谢谢。
答案 0 :(得分:2)
看起来Mail::IMAPClient->new
不喜欢套接字和服务器/端口。如果我使用服务器/端口创建套接字然后传递它,它确实连接成功。
sub connectGMail
{
my $socket = IO::Socket::SSL->new
(
PeerAddr => 'imap.gmail.com',
PeerPort => 993,
SSL_verify_mode => SSL_VERIFY_NONE
)
or die "socket(): $@";
my $client = Mail::IMAPClient->new
(
User => 'whateverUser',
Password => 'aG00dP455w0rd'
Socket => $socket
)
or die "Cannot connect ($@)\n";
return $client;
}