---
title: How do I configure MDaemon and Microsoft 365 to use the same domain name?
description: The following article can be followed to share users between MDaemon and Microsoft 365.
---

[Skip to content](https://knowledge.mdaemon.com/configure-mdaemon-microsoft-365-to-use-the-same-domain-name#main-content)

[![](https://knowledge.mdaemon.com/hs-fs/hubfs/MDaemon-Technologies_logo.png?width=200&height=150&name=MDaemon-Technologies_logo.png)](https://mdaemon.com/)

- [Knowledge Base Home](https://knowledge.mdaemon.com/)
- [Go to www.mdaemon.com](https://mdaemon.com/)

Open main navigation

Close main navigation

- [Knowledge Base Home](https://knowledge.mdaemon.com/)
- [Go to www.mdaemon.com](https://mdaemon.com/)
- [Contact Us](https://mdaemon.com/pages/contact-us)

[Contact Us](https://mdaemon.com/pages/contact-us)

 Knowledge Base

- There are no suggestions because the search field is empty.

1. [Knowledge Base Home](https://knowledge.mdaemon.com/?hsLang=en)
2. [MDaemon Email Server](https://knowledge.mdaemon.com/mdaemon-email-server?hsLang=en)

# How do I configure MDaemon and Microsoft 365 to use the same domain name?

## The following article can be followed to share users between MDaemon and Microsoft 365.

To configure Microsoft 365 to send mail for unknown local users to MDaemon.

1. Sign into the Microsoft 365 Administrator account
2. Go to Admin Centers \\ Exchange
3. Go to Mail Flow \\ Accepted Domains.
4. Double click the domain to modify
5. Select the radio button for Internal Relay
6. Click Save
7. Go to Connectors and click the “+” button.
8. In the From drop down select Microsoft 365
9. In the To drop down select “Your organization’s email server”
10. Click Next
11. Enter a Name and a Description
12. Click Next
13. Select Only when email messages are sent to these domains.
14. Click the “+” button
15. Enter the shared domain name.
16. Click Next
17. Click the “+” button
18. Enter the FQDN of the MDaemon email server.
19. Click Next
20. Click Next
21. Click the “+” button
22. Enter an email address to validate the connection.
23. Click OK
24. Click OK
25. Click Validate
26. Click Close
27. Click Save

To configure Microsoft 365 to send outbound email to MDaemon

1. Sign into the Microsoft 365 Administrator account
2. Go to Admin Centers \\ Exchange
3. Go to Mail Flow \\ Connectors
4. Click the “+” button
5. Enter a name and description then click Next
6. Select only when email messages are set to these domains
7. Click the “+” button
8. Enter “\*” and Click OK
9. Click Next
10. Select Route email through these smart hosts
11. Click the “+” button
12. Enter the FQDN of your MDaemon server
13. Click Next
14. Click Next
15. Click Next
16. Click “+” and Enter an address to validate the connector
17. Click OK
18. Click OK
19. Click Validate
20. Click Close
21. Click Save

MX Records should be setup to point to MDaemon.  MDaemon will need to properly handle email for the Microsoft 365 accounts.  We recommend that you create accounts for all users of the domain in MDaemon.  Accounts for users that will be retrieving their email from Microsoft 365 should be configured to forward all mail to Microsoft 365.

For example, we have a domain test.com setup with accounts in MDaemon and in Microsoft 365.  [User1@test.com](mailto:User1@test.com) retrieves their email from MDaemon, [user2@test.com](mailto:user2@test.com) retrieves their email from Microsoft 365. 

MDaemon should have accounts for [user1@test.com](mailto:user1@test.com) and [user2@test.com](mailto:user2@test.com).  The account for [User2@test.com](mailto:User2@test.com) needs to be configured to forward all mail to the Microsoft 365 host name.  To do this open the MDaemon configuration session and go to: 

1. Select Accounts / Account Manager
2. Select the User2 account
3. Click **Edit** to bring up the Account Editor
4. Select **Forwarding**
5. Check **Enable mail forwarding**
6. Enter the forwarding address as [user2@test.com](mailto:user2@test.com)
7. Enter the Microsoft 365 hostname in backets in the **Domain, \[Host\], or IP** text box. 
     - For example: \[test-com.mail.protection.outlook.com\]
8. Uncheck **Retain a local copy of forwarded mail**
9. Click **OK **

MDaemon should be configured to use the local address in the SMTP envelope when forwarding mail.

1. Select Security / Security Manager / Sender Authentication / SPF Verification
2. Verify **Use local address in SMTP envelope when forwarding messages** is enabled.

MDaemon must be configured to allow Microsoft 365 to send email as a local user without the need to authenticate. 

1. Open MDaemon and select Security / Security Manager / Sender Authentication / SMTP Authentication
2. Click the check box next to **...unless message is to a local account** to enable the exclusion.
3. Click Apply

When enabling the above option, the IP Shield should be utilized to prevent any other local to local messages that are not authenticating.  Adding the domain/IP pairs to the IP Shield and bypassing the IP Shield with authenticated sessions will prevent this.

1. In MDaemon select Security / Security Manager / Sender Authentication / IP Shield
2. Check the box to **Enable IP Shield  **
3. Check the box for **Do not apply IP Shield to Authenticated sessions**
4. Add the IP ranges used by Microsoft 365 to send mail.

One way to find these IPs is by using nslookup. Open a command prompt and run the following commands:

- **nslookup -type=txt spf.protection.outlook.com**
- **nslookup -type=txt spfd.protection.outlook.com**

Instead of manually entering the large number of IP ranges in the MDaemon configuration session or Remote Administration.  Open the **IPShield.dat** file in a text editor in the **\\MDaemon\\App** folder on the server to copy/paste in entries.  

**Please read the commented documentation and verify the syntax is properly followed.**

 

- [MDaemon Email Server](https://knowledge.mdaemon.com/mdaemon-email-server?hsLang=en#main-content)
  
  
  
  
  
    - [Mobile Device Management](https://knowledge.mdaemon.com/mdaemon-email-server?hsLang=en#mobile-device-management)
- [MDaemon AntiVirus (SecurityPlus)](https://knowledge.mdaemon.com/mdaemon-antivirus-securityplus?hsLang=en)
- [ActiveSync for MDaemon](https://knowledge.mdaemon.com/activesync-for-mdaemon?hsLang=en)
- [MDaemon Connector for Outlook (Outlook Connector)](https://knowledge.mdaemon.com/mdaemon-connector-for-outlook-outlook-connector?hsLang=en)
- [SecurityGateway for Email Servers](https://knowledge.mdaemon.com/securitygateway-for-email-servers?hsLang=en)
- [RelayFax Network Software](https://knowledge.mdaemon.com/relayfax-network-software?hsLang=en)

[![Chill listening crop-3](https://knowledge.mdaemon.com/hs-fs/hubfs/belch.io/template-assets/MDaemon-Technologies_logo.png?width=199&height=41&name=MDaemon-Technologies_logo.png "Chill listening crop-3")](https://www.mdaemon.com)

[Knowledge Base Home](https://knowledge.mdaemon.com?hsLang=en)

<https://www.youtube.com/c/MDaemonTechnologies> <https://www.linkedin.com/company/mdaemon-technologies/> <https://www.facebook.com/MDaemon.Technologies/> <https://www.twitter.com/MDaemon_Email>

Copyright © 2025, MDaemon Technologies