PerlingAround has asked for the wisdom of the Perl Monks concerning the following question:


I'm atm trying to write up a perl script, that I need to monitor my new Office 365 mailbox and I am having some problems. I am currently using the module "Net::IMAP::Simple as I have previously used it to query data from another older IMAP Server. So to test the basics I simply try to connect, login and logout to and from the server.

But it seems like my script simply refuses to properly login to the Server, as anything I try produces the Error-String "Command received in invalid state". Browsing some other sites, I found out, that this Error usually is fixed by using "plain" authentication, an Option I can't seem to find within Net::IMAP::Simple, and all my other searches ended up leading me to modules for use on the IMAP-Server itself.

So what I need help with, is to find out if there is a way to login to the server using the Net::IMAP::Simple Module, or if it is simply not possible that way. If that's the case, I'd be delighted if someone could point me in the direction of a way to actually do it.

Finally, the End-Goal of this Operation is to search for the last unseen mail and read how old it is. Since I can't even login right now, I pushed that issue back a bit, and am focusing on getting the login to work first. If any of you have an idea of how to do this too, that would just be the cherry on top.

Please keep the Solutions "Newb-friendly" though. I am only rarely forced to write Perl-Scripts and usually they are quite short or at the least quite easy to come by, so I am not 100% involved in the whole module-management part.

Thank you for the help in advance