I have used oauth2_imap for Micorosft accounts. The complete instructions can be found here.
https://imapsync.lamiral.info/oauth2/oauth2_imap/README_oauth2.txt
I entered the additional data required for retrieval in the Mailcow web interface. I also created a new cron job that renews the token(s) every 30 minutes. The retrieval of emails now works.
### In a short summary, this is how I proceeded:
Download the file “oauth2_imap.zip” from https://imapsync.lamiral.info/oauth2/
After unpacking the ZIP file, I ran a first test under Windows with the command
oauht2_imap.exe <mail address>
made. This opens a Microsoft login page in the browser. After logging in with the user data of the mail address, you are asked whether you want to give access to the Thunderbird app (the script identifies itself as such). If you confirm this, the first token is generated and saved. This must be done once for each e-mail address.
In Linux, I have created my Mailcow config files in/opt/mailcow-dockerized
and all further details refer to this directory.
In the directory /opt/mailcow-dockerized/data/conf/dovecot/ I have unpacked the ZIP file oauth2_imap.zip again. I then copied the opposing token files (in the directory of the same name) from the Windows computer to the Linux computer in the same folder.
In “Edit Sync Jobs” I entered the following additional parameter under Custom Parameters
--oauthaccesstoken1=/etc/dovecot/oauth2_imap/tokens/oauth2_tokens_real-mailadress.txt
(The specified path must be accessible within the container and is therefore written as such. It can be accessed externally under/opt/mailcow-dockerized/data/conf/dovecot/
)
Create a Cron.sh in the oauth2_imap directory with the following content:
#!/bin/bash
# Renewal of the token
cd /opt/mailcow-dockerized/data/conf/dovecot/oauth2_imap/
#./oauth2_imap real-mailaddress
./oauth2_imap real-mailadress1 >/dev/null 2>&1
./oauth2_imap real-mailadress2 >/dev/null 2>&1
chmod +x cron.sh
Then just crontab -e and insert the following content:
*/30 * * * * * /opt/mailcow-dockerized/data/conf/dovecot/oauth2_imap/cron.sh >/dev/null 2>&1
That’s actually it ;-)