I am trying to use Mail :: IMAPClient to connect to an MS Exchange mailbox. Reading messages in INBOX and depending on content formats and sending messages by e-mail to other mailboxes.
This snippet is a test for connecting only using IMAP, and then disconnects. The snippet cannot connect, but I can connect using openssl.
!/usr/bin/perl
use strict;
use warnings;
use Mail::IMAPClient;
use lib "/usr/local/share/perl5";
my $IMAPserver = "imapx.servers.net";
my $IMAPuser = "emailUser";
my $IMAPpass = "resUliame";
my $IMAPport = 993;
print "Start\n";
my $client = Mail::IMAPClient->new(
Server => $IMAPserver,
Port => $IMAPport,
User => $IMAPuser,
Password => $IMAPpass,
Ssl => 1,
DEBUG => 1
)
or die "new(): $@";
$client->State(Mail::IMAPClient::Connected);
$client->logout();
print "Done\n";
This is the result that I get ...
Start
Started at Mon Sep 26 10:28:16 2016
Using Mail::IMAPClient version 3.38 on perl 5.010001
Connecting with IO::Socket::SSL PeerAddr imapx.servers.net PeerPort 993 Proto tcp Timeout 600 Debug 1
ERROR: Unable to connect to imapx.servers.net: at /usr/local/share/perl5/Mail/IMAPClient.pm line 370.
Mail::IMAPClient::connect(Mail::IMAPClient=HASH(0x2064b98)) called at /usr/local/share/perl5/Mail/IMAPClient.pm line 313
Mail::IMAPClient::new("Mail::IMAPClient", "Server", "imapx.servers.net", "Port", 993, "User", "emailUser", "Password", "resUliame", ...) called at ./testEmail.pl line 17
new(): Unable to connect to imapx.servers.net: at ./testEmail.pl line 17
I can connect to openssl, so I know that the server, port, user and password are correct.
# openssl s_client -connect imapx.servers.net:993 -crlf
CONNECTED(00000003)
* OK The Microsoft Exchange IMAP4 service is ready.
* LOGIN emailUser resUliame
* OK LOGIN completed.
* SELECT Inbox
* 28027 EXISTS
* 1 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UNSEEN 27544] Is the first unseen message
* OK [UIDVALIDITY 64268] UIDVALIDITY value
* OK [UIDNEXT 46567390] The next unique identifier value
* OK [READ-WRITE] SELECT completed.
source
share