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

时间:2011-11-11 21:15:25

标签: perl exchange-server imap

尝试使用Mail::IMAPClient连接到Exchange服务器时,我一直收到NO LOGIN失败消息。从我所读到的一切都应该有效。我已经将它连接到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.

1 个答案:

答案 0 :(得分:1)

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

快速Google“Exchange 2010 NTLM IMAP”出现了Discontinued Features from Exchange 2007 to 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。