in reply to Accessing IMAP-Server Outlook.office365.com via Perl
It can also be extremely useful to use a tool like WireShark, TCPDump, or what-have-you to see what packets are actually being exchanged between the two parties. Start by eavesdropping on an actual connection to Office ... of course most if not all of it will be encrypted and thus unreadable ... then, watch what happens when your program runs. The root cause of the problem will probably be very quickly apparent once you can see it. Guesses are usually not very useful.