I am trying to connect to an email account with the imaplib python module but it doesn't work. With @outlook it works fine for me, but with @mydomain it doesn't work.
It's not a credential issue because I tried a POP connection and it worked, but not with imap.
I have searched in many places and it happens to many but I do not see a solution. Someone who can help me?
There's a few things to look at. First, make sure IMAP access is enabled in the settings of whatever service you're using. (Eg, Gmail: Settings > Forwarding and POP/IMAP > Enable IMAP). This is often not enough to fix the issue though, you need to set up an app password. (Eg, Google: https://myaccount.google.com/security > Enable 2-step verification if it is off > App passwords). An app password lets you sign into a service using a generated password in lieu of your main account password. Use this app password in your credentials while logging in with imaplib, and it should work. I'd suggest considering using a Microsoft app password too when using imaplib for Outlook, as it's more secure. You aren't storing your actual MS password in plain-text anywhere. Hope that helps.