ERPNext

ERPNext

Open in ChatGPT
Ask ChatGPT about this page
Open in Claude
Ask Claude about this page

Setup Microsoft Mail Account

From 2025 on, basic authentication is not enough to send emails from a Microsoft 365 Account. You have to setup OAuth from now on. In this guide we will lead you through the steps for setting it up.

Step 1

First, you need to setup a Email Domain in ERPNext with the following settings.

Incoming Server outlook.office365.com
Use IMAP True
Use SSL True
Validate SSL Certificate True
Port 993
Attachment Limit 30 (Can be higher according to your Microsoft settings)
Outgoing server smtp.office365.com
Use TLS True
Use SSL False
Validate. SSL Certificate True
Port 587

Step 2

Create a connected app called: Microsoft 365

Name Microsoft 365
OpenID configuration https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration

Afterwards press "Get OpenID Configuration"

Add the following scopes:

Step 3

Create the endpoint in Microsoft:

  • In Microsoft Azure, create App Registration
  • Create your own Application
  • Name it ERPNext, leave the redirect URI empty
  • Add these permissions for Microsoft Graph as delegated permissions:
    • IMAP.AccessAsUser.All
    • offline_access
    • SMTP.Send
    • User.Read
  • Copy the application ID and fill that into ERPNext > Client ID
  • Certificates & Secrets -> New Client Secrets
  • Fill the Secret into ERPNext > Secret
  • Add Authentication Redirect URI in Azure > Web > Paste the URI from ERPNext

Step 4

  • Open a private Window and sign into the Mail you wish to send the mails from
  • Go to the connected app with your System Manager User and press "Connect to Microsoft 365" using your organizations admin account
  • You should have a token now

Step 5

  • Change your method form your email account to oAuth and the domain to your previously created one.
  • Login with the real Email Account

Recommended settings

Email Account

Enable Automatic Linking of Documents True
Default Outgoing True
Send unsubscribe message in Email False
Always use this email address as sender address True
Always use this name as senders name True

Common errors

  • SMTP Authentication not successful
    • Check under the User > Email > Manage Email Apps > Enable Authenticated SMTP
Last updated 20 hours ago
Was this helpful?
Thanks!