Setting Up NeoMutt with Office 365#
This tutorial configures an Exchange Online account using OAuth2 for IMAP and SMTP. If youβre brand new to NeoMutt, read Getting Started first.
Prerequisites#
A Microsoft 365 account (work or school).
An Azure app registration for OAuth2 (client ID and secret if required).
NeoMutt installed with IMAP and SMTP support.
The
mutt_oauth2.pyhelper script from the NeoMutt contrib directory.
If you donβt already have an Azure app registration, follow the Microsoft docs linked below.
Configure IMAP Access#
Add IMAP settings:
set imap_user = "you@yourdomain.com"
set folder = "imaps://outlook.office365.com/"
set spoolfile = "+INBOX"
Confirm NeoMutt can open the mailbox.
Expected result: the Office 365 inbox appears in the index.
Set Up SMTP for Sending#
Add SMTP settings:
set smtp_url = "smtp://smtp.office365.com:587/"
Expected result: NeoMutt is configured to send via Office 365 SMTP.
Configure OAuth2 Authentication#
Office 365 requires OAuth2 for IMAP/SMTP.
Use mutt_oauth2.py to obtain tokens.
Register an OAuth app in Azure and note the client ID (and secret if used).
Authorize tokens with
mutt_oauth2.py(see its README for the exact command).Configure NeoMutt to use OAuth:
set imap_authenticators = "oauthbearer:xoauth2"
set imap_oauth_refresh_command = "/path/to/mutt_oauth2.py you@yourdomain.com.tokens --provider microsoft"
set smtp_oauth_refresh_command = "$imap_oauth_refresh_command"
Expected result: NeoMutt authenticates to IMAP and SMTP without storing a password.
For safer storage of secrets, see Password Manager.
Read and Send Test Emails#
Start NeoMutt and open the inbox.
Compose a message to yourself and send it.
Expected result: the message appears in Sent Items and arrives in your inbox.
Handle Calendar Invites#
Open a message with a calendar invite.
Save the
.icsattachment and open it with your calendar tool.
Expected result: the invite is visible in your calendar tool.
Troubleshooting#
If login fails:
Confirm your tenant allows IMAP/SMTP OAuth access.
Re-run
mutt_oauth2.pyauthorization if tokens expired.Verify server names and ports.
References:
Exchange Online OAuth2 for IMAP/SMTP: https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
Exchange Online server settings: https://learn.microsoft.com/en-us/exchange/troubleshoot/administration/incorrect-settings-in-outlook-desktop-application
Next Steps#
βI want a quick tour of NeoMutt.β See Getting Started.
βI want to read and send mail.β Continue with Reading Your First Email and Sending Email.
βI want multiple accounts.β Continue with Multiple Accounts.