I have searched for days but finally run out of options, one of my clients move its emails accounts to "outlook.office365.com", now all my perl scripts fails because they have a different set of configurations on their platform, so i had to rewrite all of my perl scripts to make everything work again, i was aible to send emails with the module "Email::Sender::Transport::SMTP::TLS" but i didnt had the same luck using my old modules to read and proccess emails such as "Mail::POP3Client".
This is the code a try:
use Mail::IMAPClient;
use Email::MIME;
my $username = 'user';
my $password = 'pass';
my $server = 'outlook.office365.com';
print "Anon connect to IMAP\n";
my $imap = Mail::IMAPClient->new(
Server => $server,
Username => $username,
Password => $password,
Port => 993,
Ssl => 1,
Authmechanism => "PLAIN",
Debug => 1,
)or die "Cannot connect to $mailhost as $username: $@";
print "upgrading connection to TLS \n";
$imap->starttls
(
SSL_verify_mode => 0,
) or die "starttls failed: $@\n";
$imap->User($username);
$imap->Password($password);
print "Logging In\n";
$imap->login() or die "imap login failed: $@\n";
This is a solution that i have found on stackoverflow but it doesnt work for me, i checked my firewall configuration and everything is ok.
This is the output:
Anon connect to IMAP
Started at Fri Dec 16 13:54:25 2016
Using Mail::IMAPClient version 3.38 on perl 5.022001
Connecting with IO::Socket::SSL PeerAddr outlook.office365.com PeerPort 993 Proto tcp Timeout 600 Debug 1
ERROR: Unable to connect to outlook.office365.com: at C:/Perl64/site/lib/Mail/IMAPClient.pm line 370.
Mail::IMAPClient::connect(Mail::IMAPClient=HASH(0xcac170)) called at C:/Perl64/site/lib/Mail/IMAPClient.pm line 314
Mail::IMAPClient::new("Mail::IMAPClient", "Server", "outlook.office365.com", "Username", "user", "Password", "pass", "Port", 993, ...) called at dont.pl line 10
Cannot connect to as user: Unable to connect to outlook.office365.com: at dont.pl line 10.
To check my SSL connection:
openssl s_client -connect outlook.office365.com:993
Results:
* OK The Microsoft Exchange IMAP4 service is ready.
So any ideas?, what is wrong with this code?
EDIT: thanks to Max, finally a solution: removing startls allows to reach the login step.
On my machine, it outputs this:
Which is normal, as I don't have a valid account.