Sign inSign up

hoelee/email-sync-oauth2

By hoelee

•Updated about 2 months ago

Multi-account IMAP sync with OAuth2 for Office 365, Gmail and any IMAP server

Image
1

187

hoelee/email-sync-oauth2 repository overview

⁠Email Sync OAuth2

Dockerized multi-account IMAP synchronization tool with OAuth2 support for Office 365, Hotmail, Outlook.com, and Gmail.

⁠Problem This Solves

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:

  • imapsync⁠ — battle-tested IMAP migration tool
  • imapsync's OAuth2 helper — token authorization and refresh for Microsoft and Google accounts
  • Docker — portable, reproducible, easy to deploy

⁠Features

FeatureStatus
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

⁠Quick Start

git clone https://github.com/hoelee/email-sync-oauth2.git
cd email-sync-oauth2
cp .env.example .env
nano .env   # edit your settings
⁠1. First-time OAuth authorization
docker compose run --rm imapsync authorize 1
# → Paste URL in browser, log in, click "Allow"
# → Token saved to ./tokens/
⁠2. Start syncing
docker compose up -d
⁠Monitor
docker logs -f email-sync-oauth2
tail -f logs/account1.log

⁠Pull from Docker Hub

docker pull hoelee/email-sync-oauth2:latest

⁠Authentication Support

ProviderAuth MethodAuto-Refresh
Hotmail / Outlook.com / Personal MicrosoftOAuth2✅ until day 90
Office 365 / Microsoft 365 (Work/School)OAuth2✅ indefinitely
Gmail / Google WorkspaceOAuth2✅
Other IMAPPasswordN/A

⁠Source

GitHub: hoelee/email-sync-oauth2⁠

⁠License

MIT License.

⁠Credits

Tag summary

Content type

Image

Digest

sha256:b03164d8b…

Size

45.8 MB

Last updated

about 2 months ago

docker pull hoelee/email-sync-oauth2