Outlook & Microsoft 365 Setup
Configure Mailpilot with Microsoft email services: Outlook.com, Hotmail.com, Live.com, and Microsoft 365 (Office 365).
Supported Microsoft Services
- Outlook.com - @outlook.com, @hotmail.com, @live.com
- Microsoft 365 - Business and Enterprise accounts
- Exchange Online - Office 365 Exchange
Prerequisites
- Microsoft account or Microsoft 365 account
- IMAP access enabled (may need admin approval for Microsoft 365)
Step 1: Enable IMAP Access
For Outlook.com/Hotmail
IMAP is usually enabled by default. To verify:
- Sign in to Outlook.com
- Click ⚙️ Settings → View all Outlook settings
- Go to Mail → Sync email
- Under POP and IMAP, ensure Let devices and apps use IMAP is checked
- Click Save
For Microsoft 365 / Office 365
Individual users:
- Sign in to Office 365
- Click ⚙️ Settings → View all Outlook settings
- Go to Mail → Sync email
- Enable IMAP access
Administrators:
IMAP may be disabled organization-wide. Admins can enable it:
- Go to Microsoft 365 Admin Center
- Navigate to Settings → Org settings → Services
- Click Modern authentication
- Ensure IMAP is enabled for the organization
Step 2: Configure Mailpilot
Add Outlook to your config.yaml:
accounts:
- name: outlook
imap:
host: outlook.office365.com
port: 993
username: ${OUTLOOK_USER} # your.email@outlook.com
password: ${OUTLOOK_PASSWORD} # Your account password
tls: true
folders:
- name: INBOX
llm_provider: openai
prompt: |
Classify this email...Step 3: Set Environment Variables
Set your Outlook credentials:
export OUTLOOK_USER="your.email@outlook.com"
export OUTLOOK_PASSWORD="your-password"Or use a .env file:
OUTLOOK_USER=your.email@outlook.com
OUTLOOK_PASSWORD=your-passwordOutlook.com: Use your regular account password (not an app password)
Microsoft 365 with MFA: You may need to use an app password or OAuth
Step 4: Test Connection
pnpm startCheck the dashboard at http://localhost:8080 for connection status.
IMAP Server Settings
| Service | IMAP Server | Port | TLS |
|---|---|---|---|
| Outlook.com / Hotmail | outlook.office365.com | 993 | Yes |
| Microsoft 365 | outlook.office365.com | 993 | Yes |
| Custom Exchange | mail.yourcompany.com | 993 | Yes |
Microsoft 365 / Office 365
Standard Configuration
accounts:
- name: work
imap:
host: outlook.office365.com
port: 993
username: ${M365_USER} # you@yourcompany.com
password: ${M365_PASSWORD}
tls: trueWith Multi-Factor Authentication (MFA)
If your organization requires MFA, you have two options:
Option 1: App Password (if supported)
Some organizations allow app passwords:
- Go to My Account → Security
- Click + Add method → App password
- Enter a name (e.g., "Mailpilot")
- Copy the generated password
imap:
host: outlook.office365.com
username: ${M365_USER}
password: ${M365_APP_PASSWORD} # Use app password, not regular passwordOption 2: OAuth 2.0 (coming soon)
OAuth support is planned for future releases. Track progress in Issue #XX.
Folder Names
Outlook uses standard IMAP folder names:
| IMAP Folder Name | Outlook Folder |
|---|---|
INBOX | Inbox |
Sent Items | Sent |
Drafts | Drafts |
Deleted Items | Deleted |
Junk Email | Junk |
Archive | Archive |
Multiple Microsoft Accounts
Process multiple Outlook/Microsoft accounts:
accounts:
- name: personal
imap:
host: outlook.office365.com
username: ${OUTLOOK_PERSONAL_USER}
password: ${OUTLOOK_PERSONAL_PASSWORD}
- name: work
imap:
host: outlook.office365.com
username: ${M365_WORK_USER}
password: ${M365_WORK_PASSWORD}Troubleshooting
"Login failed" or "Authentication error"
Causes:
- Incorrect username or password
- IMAP disabled in account settings
- MFA requires app password
- Microsoft 365 admin blocked IMAP
Solutions:
- Verify credentials are correct
- Enable IMAP access
- Use app password if MFA is enabled
- Contact Microsoft 365 admin to enable IMAP
"IMAP is disabled for this organization"
Cause: Your Microsoft 365 administrator has disabled IMAP.
Solution: Contact your IT admin to enable IMAP for your account or organization.
Connection timeout
Cause: Firewall blocking port 993 or server issues.
Solution:
imap:
host: outlook.office365.com
timeout: 60000 # Increase timeout
port: 993"Too many connections"
Cause: Outlook limits concurrent IMAP connections (typically 15-20).
Solution:
- Close other email clients
- Reduce polling frequency
- Use a dedicated account for automation
Custom Exchange Server
For on-premises Exchange or custom Exchange Online setup:
accounts:
- name: exchange
imap:
host: mail.yourcompany.com # Your Exchange server
port: 993
username: ${EXCHANGE_USER}
password: ${EXCHANGE_PASSWORD}
tls: trueCheck with your IT admin for the correct IMAP server address.
Rate Limits and Throttling
Microsoft applies rate limits to IMAP connections:
- Connection limit: ~15-20 concurrent connections
- Throttling: Aggressive polling may trigger throttling
To avoid issues:
polling_interval: 120s # Poll every 2 minutes instead of 1 minute
accounts:
- name: outlook
imap:
host: outlook.office365.com
# Connection settings
keepalive: true
timeout: 60000Security Best Practices
- Enable MFA on your Microsoft account
- Use app passwords when available
- Monitor sign-in activity in My Account → Security
- Rotate passwords regularly
- Review connected apps periodically