Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: M365_BUILDER add support for alternative MX hosts #3191

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion commands/types/dnscontrol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ declare function LOC_BUILDER_STR(opts: { label?: string; str: string; alt?: numb
*
* This sets up `MX` records, Autodiscover, and DKIM.
*
* ### Advanced example
* ### Example with MDM only
*
* ```javascript
* D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
Expand All @@ -1881,10 +1881,32 @@ declare function LOC_BUILDER_STR(opts: { label?: string; str: string; alt?: numb
*
* This sets up Mobile Device Management only.
*
* ### Example with all services and DNSSEC MX
*
* ```javascript
* D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
* M365_BUILDER("example.com", {
* mx: true, // Can be omitted as default: true
* mxHost: "o-v1.mx.microsoft", // Override the default mail.protection.outlook.com
* autodiscover: true, // Can be omitted as default: true
* dkim: true, // Can be omitted as default: true
* skypeForBusiness: true,
* mdm: true,
* initialDomain: "example.onmicrosoft.com",
* }),
* END);
* ```
*
* This sets up MX (custom), AutoDiscover, DKIM, Skype for Business/Microsoft Teams and Mobile Device Management records.
*
* Instead of the default MX target ending in `mail.protection.outlook.com`, this example uses `<random-id>.mx.microsoft` which is a DNSSEC signed zone.
* `<random-id>` is obtained from Microsoft after [enabling DNSSEC functionality for the domain](https://learn.microsoft.com/purview/how-smtp-dane-works#inbound-smtp-dane-with-dnssec) within Exchange Online.
*
* ### Parameters
*
* * `label` The label of the Microsoft 365 domain, useful if it is a subdomain (default: `"@"`)
* * `mx` Set an `MX` record? (default: `true`)
* * `mxHost` Set your MX host for Exchange Online (default: `mail.protection.outlook.com`)
* * `autodiscover` Set Autodiscover `CNAME` record? (default: `true`)
* * `dkim` Set DKIM `CNAME` records? (default: `true`)
* * `skypeForBusiness` Set Skype for Business/Microsoft Teams records? (default: `false`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ parameters_object: true
parameter_types:
label: string?
mx: boolean?
mxHost: string?
autodiscover: boolean?
dkim: boolean?
skypeForBusiness: boolean?
Expand Down Expand Up @@ -42,7 +43,7 @@ END);

This sets up `MX` records, Autodiscover, and DKIM.

### Advanced example
### Example with MDM only

{% code title="dnsconfig.js" %}
```javascript
Expand All @@ -62,10 +63,34 @@ END);

This sets up Mobile Device Management only.

### Example with all services and DNSSEC MX

{% code title="dnsconfig.js" %}
```javascript
D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
M365_BUILDER("example.com", {
mx: true, // Can be omitted as default: true
mxHost: "o-v1.mx.microsoft", // Override the default mail.protection.outlook.com
autodiscover: true, // Can be omitted as default: true
dkim: true, // Can be omitted as default: true
skypeForBusiness: true,
mdm: true,
initialDomain: "example.onmicrosoft.com",
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trailing comma should be removed, I think.

END);
```
{% endcode %}

This sets up MX (custom), AutoDiscover, DKIM, Skype for Business/Microsoft Teams and Mobile Device Management records.

Instead of the default MX target ending in `mail.protection.outlook.com`, this example uses `<random-id>.mx.microsoft` which is a DNSSEC signed zone.
`<random-id>` is obtained from Microsoft after [enabling DNSSEC functionality for the domain](https://learn.microsoft.com/purview/how-smtp-dane-works#inbound-smtp-dane-with-dnssec) within Exchange Online.

### Parameters

* `label` The label of the Microsoft 365 domain, useful if it is a subdomain (default: `"@"`)
* `mx` Set an `MX` record? (default: `true`)
* `mxHost` Set your MX host for Exchange Online (default: `mail.protection.outlook.com`)
* `autodiscover` Set Autodiscover `CNAME` record? (default: `true`)
* `dkim` Set DKIM `CNAME` records? (default: `true`)
* `skypeForBusiness` Set Skype for Business/Microsoft Teams records? (default: `false`)
Expand Down
13 changes: 6 additions & 7 deletions pkg/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1879,15 +1879,14 @@ function M365_BUILDER(name, value) {

var r = [];

// MX host (default: "mail.protection.outlook.com")
if (!value.mxHost) {
value.mx = 'mail.protection.outlook.com';
}

// MX (default: true)
if (value.mx) {
r.push(
MX(
value.label,
0,
value.domainGUID + '.mail.protection.outlook.com.'
)
);
r.push(MX(value.label, 0, value.domainGUID + '.' + value.mxHost + '.'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PowerShell(?) commands (link to highlight, might not work in all browsers) returns the whole MX hostname: contosotest-com.o-v1.mx.microsoft.

Therefore, and to make the helper more flexible in general, I advise to do one of the following:

  1. Document how to disable the MX and set the Microsoft-provided hostname. (preferred)
  2. Allow any MX to be set, possibly multiple MXs

Documentation for the first option could look like this:

D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
  M365_BUILDER("example.com", {
      mx: false,
      …
  }),
  MX('@', 0, 'example-com.<random>.mx.microsoft.') // Note the trailing dot.
);

}

// Autodiscover (default: true)
Expand Down