Multi-account IMAP sync with OAuth2 for Office 365, Gmail and any IMAP server
187
Dockerized multi-account IMAP synchronization tool with OAuth2 support for Office 365, Hotmail, Outlook.com, and Gmail.
Microsoft retired Basic Authentication for Exchange Online (IMAP/SMTP), and Google is pushing XOAUTH2 as the only authentication method. This breaks traditional IMAP sync tools that rely on username/password.
Mailcow's built-in sync job and many other tools don't support OAuth2, making it impossible to migrate emails from Hotmail/Outlook.com/Gmail into self-hosted mail servers.
This project solves that problem by combining:
| Feature | Status |
|---|---|
| Office 365 / Hotmail / Outlook.com sync | ✅ OAuth2 |
| Gmail / Google Workspace sync | ✅ OAuth2 |
| Any IMAP server (password auth) | ✅ |
| Multiple accounts in one container | ✅ Unlimited |
| Incremental sync (only new emails) | ✅ |
| Folder structure preservation | ✅ |
| Scheduled sync via interval or cron | ✅ |
| Healthcheck endpoint | ✅ |
| One-shot sync mode | ✅ |
| Dry run mode | ✅ |
| Delete propagation | ✅ |
| Automatic token refresh | ✅ |
| SMTP sync notifications | ✅ Optional |
git clone https://github.com/hoelee/email-sync-oauth2.git
cd email-sync-oauth2
cp .env.example .env
nano .env # edit your settings
docker compose run --rm imapsync authorize 1
# → Paste URL in browser, log in, click "Allow"
# → Token saved to ./tokens/
docker compose up -d
docker logs -f email-sync-oauth2
tail -f logs/account1.log
docker pull hoelee/email-sync-oauth2:latest
| Provider | Auth Method | Auto-Refresh |
|---|---|---|
| Hotmail / Outlook.com / Personal Microsoft | OAuth2 | ✅ until day 90 |
| Office 365 / Microsoft 365 (Work/School) | OAuth2 | ✅ indefinitely |
| Gmail / Google Workspace | OAuth2 | ✅ |
| Other IMAP | Password | N/A |
GitHub: hoelee/email-sync-oauth2
MIT License.
Content type
Image
Digest
sha256:b03164d8b…
Size
45.8 MB
Last updated
about 2 months ago
docker pull hoelee/email-sync-oauth2