gpt4 book ai didi

windows - Mail::IMAPClient->new 在 Windows 中挂起

转载 作者:可可西里 更新时间:2023-11-01 10:26:29 25 4
gpt4 key购买 nike

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 中,如果我不包含 Socket 选项,它会向我显示此警告

*******************************************************************
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

如有任何帮助,我们将不胜感激,在此先致谢。

最佳答案

看起来 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;
}

关于windows - Mail::IMAPClient->new 在 Windows 中挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15621547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com