mailcow / mailcow-dockerized

mailcow: dockerized - 🐮 + 🐋 = 💕
https://mailcow.email
GNU General Public License v3.0
8.28k stars 1.13k forks source link

Office365 Oauth Import #4985

Open botsarenthuman opened 1 year ago

botsarenthuman commented 1 year ago

Summary

Office365 no longer supports IMAP PLAIN authentication. Import tasks fail due to needing an oauth token. What is needed is an oauth popup to obtain an access token.

Motivation

We can't export Microsoft mail to Mailcow without this, barring using Thunderbird to upload.

Additional context

No response

MAGICCC commented 1 year ago

You can read https://imapsync.lamiral.info/FAQ.d/FAQ.Office365.txt, tl;dr you have to use a app pasword

botsarenthuman commented 1 year ago

That appears to only work with microsoft accounts. They send you to https://account.microsoft.com/security but if you have business basic with your own domain, these options don't appear. And even if you enable and enforce2FA, they don't appear. The ability to create an "App password" appears as a 2FA method (like phone, or email), but the UI is completely different than mentioned, and still does not grant imap access (I tried twice).

MAGICCC commented 1 year ago

Ah you didnt say you have your own domain there, maybe this from the imapsync FAQ helps you then?

Q. Can imapsync work for users that are administrators for 
an Office 365 domain? (quick answer: no)

R. I doesn't seem possible to use imap for administrators, so imapsync
won't be able to work for an administrator's mailbox.
See:
https://github.com/imapsync/imapsync/issues/310#issuecomment-1002396218
https://exhaust.lewiscollard.com/post/146866104/office365-to-migadu-migration/

Solution: as explained in the article above, use Davmail as a proxy to 
access this mailbox. http://davmail.sourceforge.net/

Thanks to Lewis Collard for this report and solution.
botsarenthuman commented 1 year ago

Thanks! It's annoying that MS did this, but at least there's a workaround (besides using Thunderbird to do a download/upload)

MAGICCC commented 1 year ago

Did you manage to import your mails @botsarenthuman? If yes we may close this issue

botsarenthuman commented 1 year ago

I'll close, I'm using Thunderbird to move them. I'll investigate this later and if I find anything useful report back.

proofy commented 9 months ago

Please reopen this ticket as an improvement. Mailcow is one of the few open source products that compete with Office365 Outlook and migrating from Microsoft should be as easy as possible. The workarounds mentioned are difficult to implement even for smaller companies.

You could implement it in the first step with a token. https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth

botsarenthuman commented 9 months ago

OK I've reopened it @proofy -- but I don't know that anyone currently has a PR open to fix this.