Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to POP3 from Perl no longer works for outlook.office365.com

Tags:

perl

pop3

  1. On Ubuntu v18.04.3 LTS.
  2. POP3 server we use: outlook.office365.com
  3. POP3 port: 995
  4. Perl 5.26.1
  5. We use a Perl module Net::POP3 and we use TLS with that.
  6. This has worked for several years on the same POP server, it stopped working June 1, 2I023 and now returns a "bad username or password error". I have to wonder if they just deauthorized us for some reason on the POP3 server.
  7. Logging in using the webmail interface at outlook.com works. Doing POP3 through Perl does not.

Yesterday June 6, 2023 the module returns a login message "bad username or password error". We check for POP email every 10 minutes.

I'm not the IT person and I don't have admin privileges for our Outlook configuration.

Today we are getting a new problem where the connection variable $conn cannot create a new POP3 server.

I already read some Microsoft documents and it looks like I'm using the right protocols. We do not use SSL. From a POP3 perspective, what am I missing here?

Perl modules and code:

  1. Net::POP3 v3.15 (updated to latest version yesterday)
  2. Net::Cmd v3.15
  3. IO::Socket v1.51 (updated to latest version today)
  4. IO::Socket::IP v0.41 (no new version available)
  5. IO::Socket::SSL upgraded to v2.083 just now

How I connect:

$conn = Net::POP3->new($popserver, Timeout=>480, Port=>995,
Debug=>1);
$msg=$conn->message; # This gets the last message from the server.

This is where $conn is set to undefined and $msg=$conn->message doesn't even work at all. It takes 2.33 minutes to create the $conn Net::POP3 object above.

What I tried

  1. I updated Net::POP3 and some other IO:: modules. These are in my post.
  2. I turned on debugging for NET::POP3, the result is below.
  3. I timed how long it took to create the POP3 object $conn and it takes 2.33 minutes, less than the 480 seconds I set the Timeout to.
  4. I verified our email and password from our IT guys. We have an Outlook setup and I'm not the admin for that.
  5. I tried to trap messages with $msg=$conn=>message; but $conn is now undefined so that doesn't work.
  6. I just upgraded IO::Socket::SSL to 2.083 and I'm still getting the same error.

Debug messages from Net::POP3.

Net::POP3>>> Net::POP3(3.15)
Net::POP3>>>   Net::Cmd(3.15)
Net::POP3>>>     Exporter(5.72)
Net::POP3>>>   IO::Socket::IP(0.41)
Net::POP3>>>     IO::Socket(1.51)
Net::POP3>>>       IO::Handle(1.51)
Net::POP3: Net::Cmd::getline(): **unexpected EOF on command** channel:  at /home/chuck/perl/gilson/dataserv/dataserv.pl line 5944.
 at /usr/local/share/perl/5.26.1/Net/Cmd.pm line 257.
        Net::Cmd::_set_status_closed(Net::POP3=GLOB(0x557a2504dc38), "") called at /usr/local/share/perl/5.26.1/Net/Cmd.pm line 349
        Net::Cmd::getline(Net::POP3=GLOB(0x557a2504dc38)) called at /usr/local/share/perl/5.26.1/Net/POP3.pm line 404
        Net::POP3::response(Net::POP3=GLOB(0x557a2504dc38)) called at /usr/local/share/perl/5.26.1/Net/POP3.pm line 101
        Net::POP3::new("Net::POP3", "outlook.office365.com", "Timeout", 480, "Port", 995, "Debug", 1) called at /home/chuck/perl/gilson/dataserv/dataserv.pl line 5944

Thank you for any help!

EDIT: I turned off TLS and started using SSL and now I get "unknown user name or password" error.

Edit 6/14/23: It does look like it's a problem on Microsoft's end. There are a bunch of links talking about MS getting rid of "basic auth" which includes POP3, IMAP, and possibly SMTP servers. There's not much more that is clear to me.

The links I've found are:

  1. POP3 and IMAP4 in Exchange online. https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/pop3-and-imap4/pop3-and-imap4
  2. Deprecation of Basic authentication for POP3. https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online#pop-imap-and-smtp-auth
  3. Enable or disable modern authentication for Outlook in Exchange Online. https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/enable-or-disable-modern-authentication-in-exchange-online
  4. "The Death of IMAP for Microsoft Users". Info on the deprecation of POP3 basic auth. https://missiveapp.com/blog/modern-authentication
  5. How do you know if you are still using basic authentication? That’s actually easy to determine: check your email settings to see whether they show you’re using POP3 or IMAP as your mail server protocols. If so, you’re still using basic authentication. ''Long term, it’s wise to not use either POP3 or IMAP in email.'' https://www.computerworld.com/article/3635608/how-to-make-sense-of-microsofts-upcoming-mail-security-changes.html
  6. What basic auth is being disabled? https://answers.microsoft.com/en-us/outlook_com/forum/all/what-is-basic-auth-that-is-being-disabled-in-the/93e3f0ab-ccc0-4cfc-bdd4-ec9e913101fe
  7. New opt-in endpoint for POP3/IMAP4 clients that need legacy TLS. https://techcommunity.microsoft.com/t5/exchange-team-blog/new-opt-in-endpoint-for-pop3-imap4-clients-that-need-legacy-tls/ba-p/3710395
  8. Exchange Server TLS guidance Part 2: Enabling TLS 1.2 and Identifying Clients Not Using It. https://techcommunity.microsoft.com/t5/exchange-team-blog/exchange-server-tls-guidance-part-2-enabling-tls-1-2-and/ba-p/607761

I hope this helps someone else.

like image 510
user77853 Avatar asked Sep 06 '25 21:09

user77853


1 Answers

It's unlikely that it's a Perl problem.

Mail hosting facilities have recently begun discouraging corporate and government sites from the use of POP3, and moving towards IMAP. My e-mail client (thunderbird)'s POP3 stopped working with 365 at my workplace. Shortly thereafter, Thunderbird under POP3 started failing with my home (non-Microsoft) email as well. In both cases I had to move to IMAP.

like image 169
Tom Williams Avatar answered Sep 10 '25 04:09

Tom Williams