Configure Office 365 and Odoo

How to Configure Office 365 Mail Server work with Odoo

This article is written for Office 365 Business subscribers using it as their internal and external mailing system. When your business is growing, you can start facing a mess in your mailbox. It indicates that you need to integrate your mailing system with ERP or CRM. That way, you can continue to use your favorite mail client, while all communications are synced in a structured way into ERP/CRM for managing sales, tasks, support tickets and etc.

This guide provides 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 not clear, please leave your comments down below and we will correct 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://portal.office.com. That is needed in order to create new users and groups on the Portal.

 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.

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

How to integrate the Odoo ERP with Office 365 mail server

  • Configure Outgoing mail Server in Office 365 as Relay Server
  • Configure Catchall Email in Office 365
  • Configure Outgoing Mail Server in Odoo
  • Configure Incoming Mail Server in Odoo
  • Test Odoo ERP Emailing Setup

 

Configuring Outgoing mail Server in Office 365 as Relay Server

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 somename@anydomain.com)
 
odoo office 365

  • A little bit of clarification on why Odoo acts like this

 

Now here are the steps to configure the Outgoing Mail server.

1. Login with your Global Admin user account to https://portal.office.com/adminportal/home and click on the “Admin Center -> Exchange” menu in the left panel
 
2. In the Opened Window click on the section “mail flow -> connectors”

3. Click the “plus” sign on the opened page to add a new connector

odoo office 365

 
4. On the first screen with mail flow scenario, select the following values and click “Next”
From = “Your organization’s email server”
To = “Office 365”

odoo office 365

 
5. Give a name to the connector. E.g. “Odoo Connector”. All checkboxes should be checked (default behavior). And click Next

odoo office 365

 
6. 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.

odoo office 365

 
7. After clicking “Save” you should get the following screen with an already created connector

odoo office 365

 
Office 365’s outgoing mail server is now configured and ready to be used with Odoo. But before proceeding to Odoo-side configuration, let’s make Office 365 ready to receive incoming mails for Odoo. This is described in next step.
 

Configuring Catchall Email in Office 365

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?

 

Steps to configure Catchall Email address in Office 365 are described below:

1. Sign into https://portal.office.com/adminportal/home, go to menu “Users -> Active Users” to see list of already created users

odoo office 365

 
2. Click on the button “+ Add User”. Create a new user like “ERP Notification” with email erp@yourdomain.com. You can choose any email address you want. Note that Role of this user should be “User (no administrator access)” and Product License should have the status Office 365 Business Premium or higher (as you see near some emails in column “Status” on the image above) as this user should have a separate mailbox.

IMPORTANT! Make sure to remember the Password that is automatically displayed after you create a user.

odoo office 365

 
3. Now let’s open a separate anonymous browser window and do an initial login to the account created above. Use this URL https://outlook.office365.com/owa/ – this is direct URL to Outlook. System will ask you to change password. Remember the password also! And select other preferences.
Follow all steps until you see an empty mailbox. Now setup of the user is finished

4. Now we should go back as Global Administrator to https://portal.office.com/adminportal/home, go to menu “Exchange -> recipients -> groups” and in dropdown click “Dynamic Distribution Group”

odoo office 365

 
5. Now enter the following values in the fields:

a. Display Name = DynamicAllUsers (you can use any you want)
b. Alias = dynamicallusers (you can use any you want)
c. Members = “Users with Exchange mailboxes” and “Mail-enabled groups”

odoo office 365

 
6. In “general” settings for this group select checkbox “Hide this group from exchange address book”

odoo office 365

 
7. Now we need to 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 erp@yourdomain.com, so Odoo ERP can process and analyse them.

odoo office 365

 
8. After clicking the “+” sign to add new rule, you will be sent to a new form where you need to click the advanced properties link. As a result you will need to define the following fields:

a. “Name” = Catchall for Odoo
b. “Apply this rule if” = “Apply to all messages”
c. “Do the following” = Redirect the message to Erp Notifications (here you can select email address created in earlier stages)
d. Except if = The recipient is located Outside the organization OR The recipient is a Member of All 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)
e. Audit this rule with severity level = High (if any issues we want to debug this)
f. Mode of the rule = Enforce
g. Stop Processing more rules = Selected

odoo office 365

 
9. As a result, after saving your rule it will look like the screen below.

odoo office 365

 
10. 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 exists”. 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

odoo office 365

 
11. Now edit your domain and set its type to be an “Internal Relay” as shown on the image below

odoo office 365

 
Note: You will need to ignore the warning below

odoo office 365

 

Configuring Outgoing Mail Server in Odoo

During the previous steps, we have configured Office 365 as a Relay Server. The steps below will help configure the server to work with Odoo.

1. Go to the special online tool https://mxtoolbox.com/. This tool allows retrieving DNS records registered for your domain quickly and display them to you. Specifically, now we are searching for all MX records for our domain. Enter your domain name (e.g. yourdomain.com) in the text box and click “MX Lookup”. As a result, you will see a list of MX records. One of the records “Hostname” is ending with “outlook.com”. Copy it as we need it on the following step.

 
2. Login as Administrator in Odoo ERP and go to menu Settings -> General Settings. In the section related to emails – click “Outgoing Email Servers”. And either select an existing one (to modify it) or click the “Create” button to create a new one. You need to enter the following values only (no login and password are needed as you already made the Odoo server trusted by Office 365):

a. Description = Office 365 SMTP Server
b. SMTP Server = copied from previous step
c. Port = 25
d. Connection Security = TLS (STARTSSL)

odoo office 365

 
3. After that, save outgoing mail server and click on the button “Test Connection”. The message below should appear

odoo office 365

 

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.

1. Login as Administrator in Odoo ERP and go to menu Settings -> General Settings. In the section related to emails – click “Incoming Email Servers”. Either select an existing one (to modify it) or click “Create” to create a new one. You need to enter the following values:

a. Name = Office 365 Incoming Mail Server
b. Server Type = IMAP
c. Server Name = outlook.office365.com
d. Port = 993
e. SSL/TLS = True
f. Username = erp@yourdomain.com
g. Password = password that you set on previous steps

After saving you need to click the “Test & Confirm” button to verify that everything is properly set up.

 
2. Check that on “Advanced” Tab you have set field “Error notice template” to the value “Fetchmail – error notice”. Or in another case, when the user will send an email to a nonexistent mailbox that cannot be processed by Odoo – he will not get an error message about it.
 
3. As Administrator, enter the Debug mode and go to the menu “Settings -> Technical -> Parameters -> System Properties”. And make sure that the properties below are set up correctly:

a. 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
b. web.base.url.freeze – we recommend adding this parameter also with the value “True”. Odoo ERP’s default behavior on the login of the administrative users 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
c. mail.catchall.domain – this parameter should have yourdomain.com
d. mail.catchall.alias – enter here part of the email previously configured. For example “ERP” in case you have previously configured the email erp@yourdomain.com

odoo office 365

 

Testing Odoo ERP Emailing Setup

Finally, after performing the steps above, we can test if emails are working as expected. The easiest way to do that is to test it on a CRM pipeline.

1. As Administrator or any powerful user go to the menu “Sales -> Dashboards” and click on the “More” link in the top-right corner of the “Direct Sales” sales team. A submenu for Sales Team will be opened and from it, you will need to click “Settings”

odoo office 365

 
2. On the sales team details, enter the following details:

a. Email Alias = sales (you can enter any)
b.Accept Emails From = Everyone
c. Team Members – add some real users with real email addresses
d.Followers (in the bottom – left corner) – add users that should automatically receive mail notifications when a new lead is coming.

odoo office 365

 
3. 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 the standard to download incoming mails.

odoo office 365

 
4. Now go to the menu “Sales -> Dashboard” and click on Sales Team “Direct Sales”. You will see that a new Opportunity was automatically created from the incoming email.

odoo office 365

 
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 Odoo.Cheap 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.