title: Perl IMAP connection to Exchange using Mail::IMAPClient?
body: <p>I keep getting a NO LOGIN failed message when trying to connect to the Exchange server using <a href="http://search.cpan.org/perldoc?Mail%3a%3aIMAPClient" rel="nofollow">Mail::IMAPClient</a>. 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?</p>
  
  <pre><code>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-&gt;new(
      Server            =&gt; 'mail.server.domain',
      User              =&gt; $username,
      Password         =&gt; $password,
      Port              =&gt; 993,
      Ssl                =&gt; 1,
      Authmechanism  =&gt; $authmech,
      Debug =&gt; 1
  ) or die "Cannot connect through IMAPClient: $@\n";
  </code></pre>
  
  <p>The out put from running the script.</p>
  
  <pre><code>~]./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.
  </code></pre>