Welcome to the definitive guide for the Home Assistant Imapsync Add-on. This tool is a powerful wrapper around the industry-standard imapsync utility, designed for heavy-duty mail migration, backup, and synchronization.
- Core Concepts
- OAuth2 Authentication (Modern Auth)
- Global Configuration
- Job Configuration
- Multi-Account Sync Example
- Provider-Specific Guide (Critical)
- Advanced CLI Flags
- Performance & Large Migrations
- Troubleshooting & FAQ
- Security Best Practices
Imapsync works by connecting to two IMAP servers (Source and Destination) and copying messages between them.
- Incremental by design: It tracks which messages have already been copied. Subsequent runs will only sync new or changed messages.
- One-way sync: By default, it copies from the Source to the Destination. It does not perform two-way synchronization.
- Support for multiple accounts: You can add many independent sync pairs (e.g., A -> B, C -> D).
- Stateless: The add-on itself doesn't store your mail; it merely facilitates the transfer.
This add-on supports OAuth2 for Google (Gmail/Advanced Protection) and Microsoft (Office 365/Outlook). This is the recommended method for these providers as it avoids "Less Secure App" issues.
Located in the main configuration tab of the add-on.
| Option | Type | Default | Description |
|---|---|---|---|
sync_interval |
Integer | 3600 |
Seconds between sync cycles. Minimum: 90 (or 0 for run-once mode). |
log_level |
String | info |
Adjusts verbosity (debug, info, warning, etc.). |
Note
If sync_interval is set to 0, the add-on will execute all defined jobs once and then go into an idle state (run-once mode). You will need to restart the add-on to trigger another sync.
The jobs section is a list (array), meaning you can sync multiple accounts. This allows you to sync Account A to Account B, and Account C to Account D independently in the same cycle.
For each job, you must provide:
source_host/source_user/source_password: The source account (where the mail currently is).destination_host/destination_user/destination_password: The destination account (where the mail should go).delete_after_sync: (Boolean, Default:false) If set totrue, messages are deleted from the source after a successful transfer. WARNING: Use with caution as this action is irreversible!additional_cli_args: (Optional) Advanced flags for theimapsyncCLI.
Example:
jobs:
- source_host: imap.source.com
source_user: user@source.com
source_password: 'secret123'
destination_host: imap.dest.com
destination_user: user@dest.com
destination_password: 'secret456'
delete_after_sync: falseYou can sync completely different accounts in the same add-on run:
sync_interval: 3600
jobs:
- source_host: imap.yahoo.com
source_user: user1@yahoo.com
source_password: 'password1'
destination_host: imap.gmail.com
destination_user: user1@gmail.com
destination_password: 'password1'
- source_host: imap.outlook.com
source_user: user2@outlook.com
source_password: 'password2'
destination_host: imap.fastmail.com
destination_user: user2@fastmail.com
destination_password: 'password2'Most issues arise from provider security settings. Follow these steps exactly.
- IMAP Server:
imap.gmail.com - Enable IMAP: Settings -> Forwarding and POP/IMAP -> Enable IMAP.
- Password: You MUST use a Google App Password.
- Go to Google Account -> Security.
- Enable 2-Step Verification.
- Search for App Passwords.
- Generate one for "Other (Custom Name)" -> "Home Assistant".
- Limitations: Google has strict daily bandwidth limits (around 2.5GB for downloading and 500MB for uploading).
Caution
If your Google account is enrolled in the Advanced Protection Program, you cannot use this add-on with a private OAuth2 project or an App Password.
Google's policy for APP explicitly blocks unverified 3rd-party applications from accessing sensitive data like your Gmail via IMAP. This results in the 400: policy_enforced error when using private Clients.
Personal accounts with APP are currently incompatible with imapsync. Only Workspace accounts where an admin can whitelist the Client ID remain supported.
- IMAP Server:
imap.mail.yahoo.com - Enable IMAP: Usually enabled by default.
- Password: You MUST use a Yahoo App Password.
- Account Info -> Account Security.
- Generate app password.
- Important: Yahoo often flags "too many logins" if your sync interval is too short.
- IMAP Server:
outlook.office365.com - Modern Auth: Microsoft is phasing out "Basic Auth".
- App Password: Required if 2FA is active. Generate it via your Microsoft Account security dashboard.
- Throttling: Exchange Online is aggressive at throttling during large migrations.
- IMAP Server:
imap.mail.me.com - Password: An app-specific password is mandatory. Your Apple ID password will fail.
- Username: Try just the name part (e.g.,
johnappleseed) or the full email if it fails.
- IMAP Server:
imap.gmx.comorimap.web.de. - Activation: IMAP IS DISABLED BY DEFAULT.
- Go to Settings -> POP3/IMAP -> Enable "Send and receive emails via external program".
- TLS: Only supports TLS 1.2 or higher.
- IMAP Server:
imap.fastmail.com - Password: App password required (Settings -> Privacy & Security -> App Passwords).
Most common imapsync flags are now available directly in the Configuration UI. Use the additional_cli_args section for everything else.
- Included Folders: Use regular expressions to sync only specific folders.
- Example (Inbox Only):
^INBOX$ - Example (Inbox and Sent):
^INBOX$|^Sent
- Example (Inbox Only):
- Excluded Folders: Skip specific folders easily.
- Example (Archive):
^Archive$
- Example (Archive):
- Max Age / Size: Efficiently skip old or massive emails to speed up the sync.
- Dry Run: Always recommended when testing new filters to see results without moving data.
| Flag | Description | Example |
|---|---|---|
--truncmess |
Truncate messages if they exceed provider size limits. | - "--truncmess" |
--regexflag |
Fine-tune how flags are treated. | - "--regexflag '...'" |
For mailboxes exceeding 10GB or 100,000 messages:
- The "Pre-Sync" Strategy:
- Run a sync with
--maxage 365first to get the most recent (and relevant) mail moved quickly. - Then run a full sync without the age limit.
- Run a sync with
- Handle Attachments: Use
--maxsizeto skip massive files if your destination provider has small attachment limits. - Throttling Awareness: If you get "Connection Reset" or "Socket Closed," your provider is throttling you. Increase the
sync_intervalto be less aggressive.
- Double-check the App Password. 99% of failures are due to using the primary password.
- Verify IMAP is enabled in the provider's web interface.
- Check that the host is reachable.
- Verify your Home Assistant instance isn't behind a firewall blocking port 993 (IMAP SSL).
- Imapsync calculates message maps in RAM. For extremely large folders (1M+ emails), the add-on might hit memory limits. Use
--includeto sync specific folders at a time if this happens.
- This can happen if the UID mapping gets corrupted on one side. Imapsync is usually good at preventing this, but if it occurs, try removing
--usecachetemporarily in CLI args.
- Minimal Permissions: When creating App Passwords, select the "Mail" scope only if available.
- Secrets Storage: Always use the Home Assistant
!secrettag in your YAML configuration if you are editing via the file editor, or rely on the UI which handles masked password fields. - Regular Audits: Rotate your App Passwords every few months.
- Logs: Don't share your add-on logs publicly as they might contain folder names and email addresses.
For issues with the Imapsync software itself, visit the official imapsync documentation.