使用 Mail::IMAPClient Perl IMAP 连接到 Exchange?

发布于 2024-12-15 05:27:24 字数 2304 浏览 0 评论 0原文

尝试使用 Mail::IMAPClient 连接到 Exchange 服务器时,我不断收到 NO LOGIN failed 消息。从我读到的内容来看,一切都应该有效。我已经可以连接到 Gmail,但尝试连接到 MS Exchange 似乎更困难。什么可能导致身份验证失败?

use strict;
use warnings;
use Authen::NTLM;
use Mail::IMAPClient;

## Option variables
my $debug 
my $authmech = "NTLM";
my $username = "useraccount";
my $password = "set by prompt";

## Settings for connecting to IMAP server
my $imap = Mail::IMAPClient->new(
    Server            => 'mail.server.domain',
    User              => $username,
    Password         => $password,
    Port              => 993,
    Ssl                => 1,
    Authmechanism  => $authmech,
    Debug => 1
) or die "Cannot connect through IMAPClient: $@\n";

运行脚本的输出。

~]./status_page_msg.pl -d

Logging in as : user_account

Started at Sat Nov 12 19:20:11 2011
Using Mail::IMAPClient version 3.29 on perl 5.008008
Connecting via IO::Socket::SSL to mail.server.domain:993 Timeout 600
Connected to mail.server.domain
Read:   * OK The Microsoft Exchange IMAP4 service is ready - 'serverName'
Sending: 1 AUTHENTICATE NTLM
Sent 21 bytes
Read:   +
Sending: TlRMTVNTUAABAAAAB6IAAAoACgAgAAAAAAAAAAoAAABlYW0tc3RhdHVz
Sent 58 bytes
Read:   1 NO AUTHENTICATE failed.
ERROR: 1 NO AUTHENTICATE failed. at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 3047
        Mail::IMAPClient::authenticate('Mail::IMAPClient=HASH(0x1ac95440)', 'NTLM', 'undef') called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 443
        Mail::IMAPClient::login('Mail::IMAPClient=HASH(0x1ac95440)') called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 395
        Mail::IMAPClient::Socket('Mail::IMAPClient=HASH(0x1ac95440)', 'IO::Socket::SSL=GLOB(0x1b43e110)') called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 351
        Mail::IMAPClient::connect('Mail::IMAPClient=HASH(0x1ac95440)') called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 307
        Mail::IMAPClient::new('Mail::IMAPClient', 'Server', 'mail.server.domain', 'User', 'user_account', 'Password', 'Correct', 'Port', 993, ...) called at ./status_page_msg.pl line 63
Cannot connect through IMAPClient: 1 NO AUTHENTICATE failed.

I keep getting a NO LOGIN failed message when trying to connect to the Exchange server using Mail::IMAPClient. From what I've read everything should work. I've gotten it to connect to Gmail but trying to connect to MS Exchange is more difficult it seems like. What could be causing it to fail on authenticating?

use strict;
use warnings;
use Authen::NTLM;
use Mail::IMAPClient;

## Option variables
my $debug 
my $authmech = "NTLM";
my $username = "useraccount";
my $password = "set by prompt";

## Settings for connecting to IMAP server
my $imap = Mail::IMAPClient->new(
    Server            => 'mail.server.domain',
    User              => $username,
    Password         => $password,
    Port              => 993,
    Ssl                => 1,
    Authmechanism  => $authmech,
    Debug => 1
) or die "Cannot connect through IMAPClient: $@\n";

The out put from running the script.

~]./status_page_msg.pl -d

Logging in as : user_account

Started at Sat Nov 12 19:20:11 2011
Using Mail::IMAPClient version 3.29 on perl 5.008008
Connecting via IO::Socket::SSL to mail.server.domain:993 Timeout 600
Connected to mail.server.domain
Read:   * OK The Microsoft Exchange IMAP4 service is ready - 'serverName'
Sending: 1 AUTHENTICATE NTLM
Sent 21 bytes
Read:   +
Sending: TlRMTVNTUAABAAAAB6IAAAoACgAgAAAAAAAAAAoAAABlYW0tc3RhdHVz
Sent 58 bytes
Read:   1 NO AUTHENTICATE failed.
ERROR: 1 NO AUTHENTICATE failed. at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 3047
        Mail::IMAPClient::authenticate('Mail::IMAPClient=HASH(0x1ac95440)', 'NTLM', 'undef') called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 443
        Mail::IMAPClient::login('Mail::IMAPClient=HASH(0x1ac95440)') called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 395
        Mail::IMAPClient::Socket('Mail::IMAPClient=HASH(0x1ac95440)', 'IO::Socket::SSL=GLOB(0x1b43e110)') called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 351
        Mail::IMAPClient::connect('Mail::IMAPClient=HASH(0x1ac95440)') called at /usr/lib/perl5/site_perl/5.8.8/Mail/IMAPClient.pm line 307
        Mail::IMAPClient::new('Mail::IMAPClient', 'Server', 'mail.server.domain', 'User', 'user_account', 'Password', 'Correct', 'Port', 993, ...) called at ./status_page_msg.pl line 63
Cannot connect through IMAPClient: 1 NO AUTHENTICATE failed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彼岸花似海 2024-12-22 05:27:24

您应该说它曾经可以工作,但当服务器升级到 Exchange 2010 时停止工作。

快速 Google 一下“Exchange 2010 NTLM IMAP" 已出现 从 Exchange 2007 到 Exchange 2010 已停止使用的功能

Exchange 2010 RTM 中的 POP3 或 IMAP4 客户端连接不支持 NTLM。使用 NTLM 的 POP3 或 IMAP4 客户端程序的连接将失败。如果您运行的是 Exchange 2010 RTM,则建议替代 NTLM 的 POP3 和 IMAP4 设置是:

  • Kerberos (GSSAPI)
  • 使用 SSL 的纯文本身份验证

如果您使用的是 Exchange 2010 RTM,要使用 NTLM,您必须在 Exchange 2010 组织中保留 Exchange 2003 或 Exchange 2007 服务器。

Exchange 2010 SP1 中恢复了对 POP3 和 IMAP4 连接的 NTLM 身份验证的支持。

由于您使用的是 SSL,因此您应该能够切换到纯文本身份验证(只需删除 Authmechanism)。或者,让系统管理员安装 SP1。

You should have said that it used to work, but stopped working when the server was upgraded to Exchange 2010.

A quick Google for "Exchange 2010 NTLM IMAP" turned up Discontinued Features from Exchange 2007 to Exchange 2010:

NTLM isn't supported for POP3 or IMAP4 client connectivity in Exchange 2010 RTM. Connections from POP3 or IMAP4 client programs using NTLM will fail. If you are running Exchange 2010 RTM, the recommended POP3 and IMAP4 setting alternatives to NTLM are:

  • Kerberos (GSSAPI)
  • Plain Text Authentication with SSL

If you are using Exchange 2010 RTM, to use NTLM, you must retain an Exchange 2003 or Exchange 2007 server in your Exchange 2010 organization.

Support for NTLM authentication for POP3 and IMAP4 connectivity has been brought back in Exchange 2010 SP1.

Since you're using SSL, you should be able to switch to plain text authentication (just delete Authmechanism). Or, get your sysadmins to install SP1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文