使用 Mail::IMAPClient Perl IMAP 连接到 Exchange?
尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该说它曾经可以工作,但当服务器升级到 Exchange 2010 时停止工作。
快速 Google 一下“Exchange 2010 NTLM IMAP" 已出现 从 Exchange 2007 到 Exchange 2010 已停止使用的功能:
由于您使用的是 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:
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.