Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using cPanel and Office 365 in a hybrid scenario

Discussion in 'Workarounds and Optimization' started by Lefteris Mourikis, Feb 22, 2017.

  1. Lefteris Mourikis

    Lefteris Mourikis Registered

    Joined:
    Feb 22, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Athens, Greece
    cPanel Access Level:
    Root Administrator
    Hello,

    I landed on this thread while searching on Google for the same question as the original poster. As this thread is quite old, I cannot answer there, so I open a new one hoping this helps both the original poster and any other guy with the same question. Also, if anyone has a better suggestion, I would be glad to read it.

    While Jcats's answer is correct when speaking about email routing via DNS, it does not contain the full truth about email routing. That is because DNS is not the only way to route messages between email servers of the same organization.

    That said, let me describe a little better the options. When setting up Office 365 on a hybrid scenario between a, let's call it, on-premise server (that is your WHM/CPanel server) and Office 365 Exchange Online you have to take a decision about the primary mail server. You can either choose all mails to be routed to Exchange Online or to your on-premise server. This is done using the MX record, as Jcats mentioned. Let's take the scenario that you choose to route all emails to Exchange Online.

    First you need to create a Connector in the Exchange Online ECP. Tell the connector to be used only when a transport rule is set up (we will create that later). Specify the on-premise IP address of your email server and the desired TLS configuration, if any. Then go to Recipients -> Contacts and create new contacts for every single email address you want to use, eg info@mydomain.com, sales@mydomain.com, etc. Last, go to Mail flow -> Rules and create a new rule for every contact you created. The rule should tell that if the recipient is info@mydomain.com then use the Connector you created.

    That is all needed inside Office 365 Exchange Control Panel. Now, you need to setup also WHM/CPanel. So, go to your client's CPanel.

    First, you have to edit the TXT SPF record so that both Exchange Online and CPanel's IP address are included.

    Then, go to MX Entry and choose Local Mail Exchanger. If you don't do that CPanel sees that the MX record shows to an external mail exchanger (that is Office 365's Exchange Online) and will forward the message back to Exchange Online, creating a loop that will end with an error "Hop count exceeded". Keep in mind that in our scenario you must leave Office 365 as the value of your primary MX record (that is <yourdomain>.mail.protection.outlook.com).

    After that you will be able to use both Office 365 and WHM/CPanel in a hybrid scenario.

    The downside is that you have to check the consequences of the "Local Mail Exchanger" setting in CPanel. For example, maybe your site's contact forms will have problem sending you email to 365. It is something you have to check.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Thank you for taking the time to share an example of how this could be acheived. I've moved this thread to our "Workarounds and Optimizations" forum.

    Thanks!
     
  3. Doc_br

    Doc_br Registered

    Joined:
    Feb 28, 2017
    Messages:
    1
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Portugaç
    cPanel Access Level:
    Root Administrator
    Hello,

    Thanks for sharing this.
    I just finished implementing this solution on my server, but I couldn't send emails from my on-premises accounts to the office 365 accounts. Since we are forcing the "Local Mail Exchanger" option, any email sent to accounts on the same server would not be sent to Office 365.
    To overcome this, I setup an email forwarding to the corresponding @mydomain.onmicrosoft.com email address.
    So for the email foo@mydomain.com that is now using Office 365, I created an Email Account Forwarder to the account foo@mydomain.onmicrosoft.com

    Now it is working!
     
    cPanelMichael likes this.
Loading...

Share This Page