This article is written for Office 365 Business subscribers who use the software as their internal and external mailing system. When your business is growing, you can start facing a mess in your mailbox. This indicates that you need to integrate your mailing system with ERP or CRM, so you can continue to use your favorite mail client. Then, all communications will be synced in a structured way into ERP/CRM for managing sales, tasks, support tickets, and more.

In this guide, learn how to configure emails to work seamlessly with Office 365 and Odoo. Utilize the Odoo Outlook for bidirectional communication, access Office 365 emails in Odoo, and vice versa. Optimize the Odoo SMTP server for reliable email delivery. Configure incoming emails in Odoo to handle customer queries efficiently. Customize Odoo’s email settings for a professional brand image and streamlined communication. Boost productivity and collaboration with this integration.

As an Aโ€“Z guide, we have provided you with a full set of instructions on how to configure your Office 365 Exchange to work with the Odoo ERP system. This guide was written with the goal to be an A-Z guide. If you find that this article is not complete enough or something is unclear, please leave your comments down below and we will correct these instructions and add clarifications to it.

Prerequisites

1. Assumption is that you are already a user of the Office 365 Business subscription that includes Exchange Server. E.g. โ€œOffice 365 Business Premiumโ€.

2. You are already using mailing features from Office 365. Meaning you are not a new Office 365 subscriber. If you just purchased a subscription and havenโ€™t configured anything yet, you first need to perform an initial setup by following the official Microsoft guide. It is especially important that you already have properly configured your custom domain. This Microsoft guide can help you with this.

3. People executing the steps below need to have Administrative access (Role: Global Administrator) to https://www.office.com. That is needed in order to create new users and groups on the Portal.

4. According to official Odoo documentation, You can use an Office 365 server if you run Odoo on-premise. Office 365 SMTP relays are not compatible with Odoo Online or Odoo.sh.

For Odoo Online or Odoo.sh or at instances where it is not possible to use 25 port or without a static IP address you can configure it by following article.

If all above preconditions are already fulfilled, then you can go ahead with next steps.

Table of contents

  1. Configure Outgoing mail Server in Office 365 as Relay Server
  2. Configure Catchall Email in Office 365
  3. Install Odoo module to inform users that they used the wrong email
  4. Configure Outgoing Mail Server in Odoo
  5. Configure Incoming Mail Server in Odoo

Configuring Outgoing mail Server in Office 365 as Relay Server

Principle of Operation

In this section, you will learn how to configure Office 365 to act like a relay server.

Why is it needed?

Odoo ERP is trying to operate as a relay server. Meaning that it is used as an intermediate layer to send emails from ANY mail address to ANY mail address. For example, after this mail configuration Odoo will be able to send emails from any email (for example [email protected])

diagram  relay server

A little bit of clarification on why Odoo acts like this

Letโ€™s imagine that you are getting an email from a potential lead to the address [email protected]. Imagine that potential leadโ€™s email address is [email protected]. Odoo ERP catches this email and creates a new Opportunity in the CRM Pipeline. And after Odoo creates it โ€“ it needs to send automatic emails to all followers, to inform everybody about the new Opportunity. As it is now implemented in Odoo ERP, the email will attempt to send FROM the email of the lead (e.g. [email protected]) and not from some generic email like [email protected]. The reason why Odoo is doing it is to make sure that this email will be beautifully displayed as belonging to a real person and not to look like an automatic notification from ERP. And obviously when you respond to the person through Odoo CRM, your lead will also see that email is coming from [email protected] instead of some generic email [email protected]. So the intention of Odoo is clear โ€“ they want to ensure all messages from ERP are personal and do not look like an automatic notification. But that gives additional headache relating to the mailing system configuration.

Configuring of a SMTP relay connector

The configuration of the outgoing mail server is based on the following documentation.

  1. Login with your Global Admin user account to https://admin.microsoft.com and click on the โ€œAdmin centers -> Exchangeโ€ menu in the left panel
odoo configuring of a smtp relay connector
  1.  In the Opened Window click on the section โ€œMail flow -> Connectorsโ€
odoo configuring of a smtp relay connector
  1. Click the โ€œAdd a connectorโ€ on the opened page to add a new connector.
  2. On the first screen with mail flow scenario, select the following values and click โ€œNextโ€

From = โ€œYour organizationโ€™s email serverโ€

To = โ€œOffice 365โ€

  1. Give a name to the connector. E.g. โ€œOdooMailโ€. All checkboxes should be checked (default behavior). And click Next
odoo 15 odoo configuring of a smtp relay connector
  1. Select checkbox to verify allowed senders by IP address and add IP addresses of all your Odoo ERP instances. That is a type of whitelist. Office 365 will trust messages sent from those IP addresses as safe.
  1. After clicking โ€œCreate Connectorโ€ you should get the following screen with an already created connector
odoo 16 configuring of a smtp relay connector
odoo configuring of a smtp connector

Configuring of a Anti-spam thread policy

  1. Go back to Admin center click on the โ€œAdmin centers -> Securityโ€ menu in the left panel.
configuring of a anti spam thread policy
  1. In the Opened Window move by following path โ€œPolicies & rules -> Threat policies -> Anti-spam -> Connection filter policy (Default)โ€ and click on โ€œEdit connection filter policyโ€
configuring of a anti spam thread policy odoo
configuring of a anti spam thread policy
configuring of a anti spam thread policy odoo 14
configuring of a anti spam thread policy odoo 16
  1. Add to โ€œAlways allow messages from the following IP addresses or addresses rangeโ€ field IP addresses of all your Odoo ERP instances and click on โ€œSaveโ€.
configuring of a anti spam thread policy in odoo
configuring of a anti spam thread policy

Configuring of a Domain DNS records

  1. You need to make sure that your domain has required DNS records. For this go back to Admin center and move by following path: “Settings -> Domains -> Your Domain -> DNS records”
configuring of a domain dns records
configuring of a domain dns records in odoo 15
  1. We are interested in MX and SPF records. Check that the MX record looks like following structure:

<subdomain(optional)>-<second level domain(SLD)>-<top level domain (TDL)>.mail.protection.outlook.com

Example: contoso-com.mail.protection.outlook.com (domain with replaced dots to dash before .mail.protection.outlook.com).

configuring of a domain dns records

If the MX DNS record does not match with mentioned structures, you should add them by the Admin panel of your domain provider. 

  1. Check that SPF record contain IP addresses of all your Odoo ERP instances and looks like following structure:

v=spf1 ip4:<your_ip> ip4:<your_other_ip(optional)>  include:spf.protection.outlook.com ~all

configuring of a domain dns records odoo 14

If the SPF DNS record does not match with mentioned structures, you should add them by the Admin panel of your domain provider. 

IMPORTANT!

If you are trying to integrate Office 365 emails with Amazon EC2, you will need to follow this article additionally. The reason why you need this โ€“ Amazon has additional protection to prevent spammers to send emails from their servers. So you have to explicitly request from them allowance to do that.

Configuring Catchall Email in Office 365

Principle of Operation

In this section, you will learn how to create a special mail address in Office 365 that will collect emails sent to unknown receivers (meaning no User exists in Office 365).

odoo office 365

Why is it needed?

In Odoo ERP it is possible to configure multiple Sales Teams, Projects and etc. Any objects you want. For example, you may want to have a Sales Team with the name โ€œInitial Processing Teamโ€. That sales team should process leads that are received to the email address โ€œ[email protected]โ€. Also, you may want to have separate Sales Teams which will be responsible for processing emails sent to addresses โ€œ[email protected]โ€ and โ€œ[email protected]โ€ or more. 

You may configure as many email addresses as you want and obviously those email addresses will not be real emails in your Office 365 Portal.

So to avoid lots of manipulations in the Office 365 Portal when you are adding something new in Odoo ERP (new project, new sales team and etc.), it is better to configure single email addresses that will be the only endpoint for all emails sent to nonexistent mailboxes. That way Odoo ERP can easily process them, and no emails will be lost.

Configuring of a Catchall mailbox user

  1. Sign into https://admin.microsoft.com, go to menu โ€œUsers -> Active usersโ€ to see list of already created users
Catchall mailbox

If you don’t have the user which will be used like Catchall mailbox, create it by clicking on the button โ€œAdd a userโ€.The name of the user you can write  like โ€œERP Notificationโ€ with email [email protected] (recommended alias is โ€˜catchallโ€™โ€™ but you cat use any one except โ€˜bounceโ€™, as example we use โ€˜infoโ€™). Note that Role of this user should be โ€œUser (no administrator access)โ€ and Product License should have the status Exchange Online or higher.

If you have the user which will be used like Catch All mailbox, you need to make sure that it has required configuration.

Catchall mailbox odoo
  1. First of all you should go to the โ€œLicenses and appsโ€ tab and make sure that the user’s  Product License has the status Exchange Online or higher.
Catchall mailbox odoo 365
  1. After that you should go to the โ€œMailโ€ tab and make sure that the user has permissions for connections by SMTP, IMAP and POP protocols.
Catchall mailbox odoo 14
odoo 15 Catchall mailbox

Configuring of a Dynamic Distribution Group

  1. Go to the menu โ€œAdmin Center -> Exchange -> Recipients -> Groupsโ€, choose the โ€œDynamic Distribution listโ€ tab and click “Add a group”.
configuring-of-a-dynamic-distribution-group
  1. Choose the “Dynamic distribution” point and click โ€œNextโ€.
2-configuring-of-a-dynamic-distribution-group
  1. Now enter the following values in the fields and click โ€œNextโ€:
    • Name = โ€œDynamic All Usersโ€ (you can use any you want)
    • Description = โ€œDynamic All Usersโ€ (you can use any you want)
3-configuring-of-a-dynamic-distribution-group
  1. Choose the following values in the fields and click โ€œNextโ€:
    • Members = โ€œUsers with Exchange mailboxesโ€ and โ€œMail-enabled groupsโ€
4-configuring-of-a-dynamic-distribution-group
  1. Enter the following values in the fields and click โ€œNextโ€:
    • Alias = โ€œalldynamicusersโ€ (you can use any you want)
    • Domain = the same domain like for Catchall mailbox
5-configuring-of-a-dynamic-distribution-group
  1. Confirm the group creation by clicking โ€œCreate groupโ€
6-configuring-of-a-dynamic-distribution-group

As result you can see the same as at examples below:

7-configuring-of-a-dynamic-distribution-group7-configuring-of-a-dynamic-distribution-group
8-configuring-of-a-dynamic-distribution-group

Configuring of a Mail Flow Rule

  1. Go to the menu โ€œAdmin Center -> Exchange -> Mail flow -> Rulesโ€. In this section we are going to create a special mail flow rule that will allow you to catch all emails to unknown email addresses and will forward them to [email protected], so Odoo ERP can process and analyze them. Click the โ€œAdd a ruleโ€ and choose the โ€œCreate a new ruleโ€.
1-configuring-of-a-mail-flow-rule
  1. In opened form enter the following values in the fields and click โ€œNextโ€:
    • Name = โ€œCatchall for Odooโ€
    • Apply this rule if = โ€œApply to all messagesโ€
    • Do the following = Redirect the message to your Catchall user (here you can select email address created in earlier stages)
    • Except if = The recipient is located โ€œNotInOrganizationโ€ OR The recipient is a Member of All Dynamic Users group (those rules are needed not to do anything with messages that are sent to external email addresses or that are sent to real users in your organization)
2-configuring-of-a-mail-flow-rule
  1. Then enter the following values in the fields and click โ€œNextโ€:
    • Rule mode = โ€œEnforceโ€
    • Severity = โ€œHighโ€ (if any issues we want to debug this)
    • Stop Processing more rules = Selected
3-configuring-of-a-mail-flow-rule
  1. As a result, after saving your rule it will look like the screens below.
4-configuring-of-a-mail-flow-rule

Configuring of a Internal Relay for Accepted Domain

  1. Note that after executing the above, the process is not finished yet. Now if you try to send email to non-existent email addresses, Microsoft will bounce back this email to the user saying that โ€œSuch email address does not existโ€. We need to switch off this feature of Microsoft on our domain (but later we will need to replicate it on Odoo side, but that is next steps). For now, we should go to the menu โ€œAdmin Center -> Exchange -> Mail flow -> Accepted domainsโ€ and find our domain
1-configuring-of-a-internal-relay-for-accepted-domain
  1. Now edit your domain and set its type to be an โ€œInternal Relayโ€ as shown on the image below
2-configuring-of-a-internal-relay-for-accepted-domain
3-configuring-of-a-internal-relay-for-accepted-domain

Configuring of a Azure App for connection to Catchall mailbox

  1. To have the possibility to connect to the Catchall mailbox from Odoo it is needed to create an entrypoint with special permissions. To do this we should go to the menu โ€œAdmin Center -> Azure Active Directory admin center -> Azure Active Directory -> App registrationโ€ and click โ€œNew registrationโ€.
1-configuring-of-a-azure-app-for-connection-to-catchall-mailbox
  1. Enter the following values in the fields and click โ€œRegisterโ€:
    • Name = โ€œOdooMailโ€ (you can use any you want)
    • Supported account types = โ€œAccounts in any organization directory and personal Microsoft accountsโ€
    • Redirect URI = โ€œWebโ€ and โ€œhttps://your-domain.com/microsoft_outlook/confirmโ€ (domain of your odoo instance, it can be not same as mail domain)

In the result we see a new app. Be sure to copy and save the โ€œApplication (client) IDโ€, it will be required in configuring of a connection to Catchall mailbox from Odoo. 

  1. Then we should give the app special permissions. For this go to the โ€œApp permissionsโ€ and click โ€œAdd a permissionโ€.
  1. In the form go to the โ€œMicrosoft APIsโ€ tab and click โ€œMicrosoft Graphโ€.
  1. After that choose โ€œDelegated permissionsโ€, find and check โ€œSMTP.Sendโ€, โ€œIMAP.AccessAsUser.Allโ€, โ€œIMAP.AccessAsUser.Allโ€ and then click โ€œAdd permissionsโ€.

As a result we will see the same as in the example below.

  1. Now we should create the app secret key. For this go to โ€œCertificates & secretsโ€, choose the โ€œClient secretsโ€ tab and click โ€œNew client secretsโ€.
  1. Enter the following values in the fields and click โ€œAddโ€:
    • Description = โ€œOdooMailโ€ (you can use any you want)
    • Expiries = Choose any secret expires you want

As a result we will see the same as in the example below. Be sure to copy and save the โ€œValueโ€ of the created “Client secret”, it will be required in configuring of a connection to Catchall mailbox from Odoo. 

Note. If the domain of your odoo instance was changed you should update “Redirect URL” as shown below.

Installing Odoo module to inform users that they used the wrong email

In the previous steps, we have configured Office 365 so it will accept all emails sent to a specific domain, even if those email addresses donโ€™t exist. This means users will not even know that they made a mistake and used the wrong email address. For that purpose you need to perform the following steps:

  1. You need to install this module https://www.odoo.com/apps/modules/15.0/fetchmail_notify_error_to_sender/ At the moment of writing this module is available only for Odoo 9-15. If you need this module with other versions, please let us know.
  1. After installing this module, when some user is sending an email to some mail address that does not exist in Office 365 and does not exist in Odoo ERP (no objects are associated with it), then he will receive the message below automatically.
1-installing-odoo-module-to-inform-users-that-they-used-the-wrong-email

Configuring Outgoing Mail Server in Odoo

Outgoing mail server is needed to allow Odoo to send messages and notifications to mailboxes of recipients that are inside and outside Odoo. Below are the steps needed to make this configuration and health check.

Configuring of Odoo Outgoing connection

  1. Login as Administrator in Odoo ERP, enter the Debug mode and go to “Settings -> Technical -> Outgoing Mail Servers”. Either select an existing one (to modify it) or click โ€œCreateโ€ to create a new one.
1-configuring-of-odoo-outgoing-connection
  1. Then you need to enter the following values, click at โ€œTest Connectionโ€ and save settings:
    • Description = โ€œOffice 365โ€
    • SMTP Server = MX value  from DNS records of your mail domain (see here)
    • Port = โ€œ25โ€
    • Connection Security = โ€œTLS (STARTSSL)โ€
    • From Filter = โ€œ@your-domain.comโ€ – it is needed to send messages with sender which has any alias and your mail domain but in case other domain will be used default sender alias (work since Odoo v15)

To use analog โ€œFrom Filterโ€ field in Odoo below v15 you should use the key mail.dynamic.smtp.from and set the value as the email address that should be used in those cases as shown below, for example such as [email protected] (documentation).

Testing of Outgoing Mail Server in Odoo

  1. Go to your user settings and set “Email” which will contain your mail domain. You can see example below:
  1. After that, go to any unnecessary contact, set  “Email” on which you can receive a message. Then click “Send message”, fill in any text message and click “Send” (before sending make sure that contact is a follower of the current chat).
  1. Then go to the recipient mailbox and check inbox messages. One of them has to be received from Odoo ERR like at example below.
testing-of-outgoing-mail-server-in-odoo

Configuring Incoming Mail Server in Odoo

Incoming mail server is needed to allow Odoo to scan some particular mailboxes for new emails. And depending on the โ€œToโ€ address, it can create new objects like Leads, Tasks and more (or add messages to existing objects). Below are the steps needed to make this configuration and health check.

Configuring of Odoo Incoming connection

  1. Login as Administrator in Odoo ERP, go to the โ€œAppsโ€ menu, find the โ€œMicrosoft Outlookโ€ app  and click โ€œInstallโ€.
configuring-of-odoo-incoming-connection
  1. Then go to โ€œSettings -> General Settings -> Discussโ€, enter the following values and click โ€œSaveโ€:
    • External Email Servers = Selected
    • Domain = the same domain like for Catchall mailbox
    • Client ID = Client ID from your Azure App (see here)
    • Client Secret = Secret Value from Azure App (see here)

If your Odoo version is v17 you should add Alias Domain in the next way:

  • Name โ€“ this parameter should have your-domain.com
  • Catchall Alias โ€“ enter here part of the email previously configured. For example โ€œinfoโ€ in case you have previously configured the email [email protected]
  1. After that go to “Settings -> Technical -> Incoming Mail Servers”. Either select an existing one (to modify it) or click โ€œCreateโ€ to create a new one.
  1. Now enter the following values and click โ€œConnect your Outlook accountโ€:
    • Name = โ€œOffice 365โ€
    • Server Type = โ€œIMAPโ€
    • Outlook = Selected
    • Username = [email protected] (Catchall mailbox)
  1. Then โ€œLoginโ€ by your Catchall mailbox user.
  1. As a result you will see that Odoo ERP got a Valid Outlook Token. So next click โ€œTest & Confirmโ€.

As you can see, the connection to the Catchall mailbox was successful.

  1. Check that on โ€œAdvancedโ€ Tab you have set field โ€œError notice templateโ€ to the value โ€œFetchmail โ€“ error noticeโ€. Or in other case, when user will send email to nonexistent mailbox that cannot be processed by Odoo โ€“ he will not get error message about it.
  1. Then go to the menu โ€œSettings -> Technical -> System Parametersโ€. And make sure that the properties below are set up correctly:
    • web.base.url โ€“ should be equal to the URL of your Odoo instance. It is needed in order to include a proper URL in all your emails
    • web.base.url.freeze โ€“ we recommend to add this parameter also with the value โ€œTrueโ€. Odoo ERPโ€™s default behavior on login of administrative user is to replace web.base.url parameter with the current url used by the admin. In most cases it is not desired behavior and we want to preserve the URL we have added
    • These settings should be checked if Odoo version is less than v17:
    • mail.catchall.domain โ€“ this parameter should have your-domain.com
    • mail.catchall.alias โ€“ enter here part of the email previously configured. For example โ€œinfoโ€ in case you have previously configured the email [email protected]

Testing of Incoming Mail Server in Odoo

  1. As Administrator or any powerful user go to menu โ€œCRM -> Sales -> Teamsโ€ and open any teamโ€™s configuration. On the sales team details, enter the following data:
    • Email Alias = โ€œsalesโ€ (you can enter any)
    • Accept Emails From = โ€œEveryoneโ€
    • Team Members โ€“ add some real users with real email addresses
    • Followers (in the chatter, optional) โ€“ add users that should automatically receive mail notifications when a new lead is coming.
1-testing-of-incoming-mail-server-in-odoo
  1. Now send something from your personal email address to the mail address specified in Sales Team. Wait for at least 5 minutes. That is the period that Odoo is configured by standard to download incoming mails.
  1. Now go to menu โ€œCRM -> Pipelineโ€ and You will see that a new Opportunity was automatically created from the incoming email with the name which is the same with email subject. If you already configured Outgoing Mail Server you can start conversation by chatter from this Opportunity.

Bingo! You are done with your configuration of Office 365 and Odoo ERP.

If you think that this article is helpful, please, share it on social networks. Sharing Icons are 

available below the article. Subscribe to our newsletter and follow Ventor.tech twitter to be kept up to date.

If you need help in configuring your Office 365 properly with Odoo ERP or found some issues / mistakes in the article, please leave your comments down below. We will be happy to assist.

Need help with your Office 365 or other Odoo integrations?

CEO & COO at VentorTech || Website || + posts

Working in IT industry full time since 2006 (as technical and functional expert)
Leading IT teams (technical and non-technical) since 2007
Lots of experience with ERP systems covering different company sizes (Oracle, Odoo)
Co-founded 2 startups (since 2010) before ending up working in business automation. Having 3 publications in Life Science
Since 2012 focusing on business automation using Odoo ERP. Is recognized as well-known expert
Working with customers across the globe (mostly NA, EMEA)
Having huge experience in Finance (managerial accounting) and Supply Chain (Logistics, Inventory, Purchase)
Passionate about creating new IT products. Having high demands to product's quality and level of customer support
Visioner and inventor in the VentorTech company.

----------------------------------------------------------------------
Education: Master.
----------------------------------------------------------------------
Experience:
Software Maintenance Team Leader
EPAM Systems

Co-founder
Boostant

ะกTO, Co-founder
XPANSA Group

----------------------------------------------------------------------
Current position: CEO & COO at VentorTech
----------------------------------------------------------------------
Since 2012 focusing on business automation using Odoo ERP. Is recognized as a well-known expert
- Working with customers across the globe (mostly NA, EMEA)
- Having a huge experience in Finance (managerial accounting) and Supply Chain (Logistics, Inventory, Purchase)

Website || + posts

1+ year of Odoo development experience
3+ years of ensuring electromagnetic compatibility for electric networks
Main skill: Python, JS, SQL, Odoo, Email Flow, S3, Redis, RabbitMQ