I am trying to connect to an Outlook email server via IMAP and the error I am getting is curious. Here is a sample of my code:
use Mail::IMAPClient;
my $imap = Mail::IMAPClient->new;
$host='outlook.office365.com';
$username='.....';
$password='.....';
$folder='INBOX';
$imap=Mail::IMAPClient->new(
Server => $host,
User => $username,
Password => $password,
Port => 993,
Ssl => 1,
Clear=> 5,
Folder => $folder,
Uid => 0,
) or die "Cannot connect to $host as $username: $@";
When I run this, the output line looks like this:
Cannot connect to outlook.office365.com as [...]: Socket closed while reading data from server.
More specifically, Socket closed while reading data from server is what is confusing me.
I specify port 993, so is the only remaining possible issue that there's a firewall in place that is preventing this? I have emailed my school's (this is a school email account) tech department (quite some time ago) and they have yet to get back, but hopefully I will hear from them soon.
I get an even stranger error when I remove the line specifying the port, I am including it only in the hopes it is somehow relevant or helpful:
Cannot connect to outlook.office365.com as [...]: Error sending '1 Login "baldassaren@wit.edu" {15} [password is shown here, along with a newline character I can't seem to force here] ' to IMAP: Bad file descriptor at ./test.pl line 10.