schedule 14-min read

DKIM for Exchange Server (On-Premises): The Honest Answer and Your Real Options

DMARC AI editorial team · Last updated

Exchange Server has no built-in DKIM signing. How to sign on-premises mail through Microsoft 365, a gateway or a transport agent, and keep DMARC aligned.

01

Introduction

Exchange Server DKIM signing does not exist as a built-in feature. Exchange Server 2016, 2019 and Subscription Edition (SE) cannot add a DKIM signature to outbound mail on their own. To sign on-premises mail you route it through Microsoft 365 and sign there, send it through a gateway or smarthost that signs, or install a third-party transport agent.

Each route changes your SPF record, your connectors and where the DKIM private key lives. This guide explains what Microsoft's documentation does and does not offer, how each option affects DMARC alignment, and a checklist for MSPs with clients still running Exchange on-premises. For the protocol background, see the DKIM guide.

02

Key takeaways

  • Exchange Server has no native DKIM signing. Its documented anti-spam agents include Sender ID and sender filtering, but nothing that signs outbound mail.
  • In a hybrid organisation, the cleanest fix is a send connector that smart-hosts internet mail through Exchange Online Protection, with DKIM enabled for the custom domain in Microsoft 365.
  • A secure email gateway or outbound smarthost that signs with the client's own domain works too, as long as it is the last system to touch the message.
  • Third-party transport agents keep signing on the Exchange server but make you responsible for key storage, updates and compatibility.
  • Exchange Server 2016 and 2019 reached end of support on 14 October 2025, so DKIM is a good moment to raise the platform question as well.
03

Does Exchange Server support DKIM signing?

No. Exchange Server 2016, 2019 and Subscription Edition have no built-in way to DKIM-sign outbound mail. Microsoft's documentation for anti-spam protection in Exchange Server lists the Sender Filter, Sender ID, Content Filter and Protocol Analysis agents, and makes no mention of DKIM or DMARC.

The list of built-in transport agents in Exchange Server tells the same story. There are agents for transport rules, data loss prevention, journaling, rights management and anti-spam, but no signing agent. Microsoft Q&A answers on this question consistently say the same thing: on-premises Exchange does not sign outbound mail with DKIM.

DKIM signing in the Microsoft world lives in Microsoft 365. The DKIM configuration guide for custom domains on Microsoft Learn covers Exchange Online and Exchange Online Protection (EOP) only. Mail that leaves the client's own Exchange server directly to the internet carries no DKIM signature unless something else adds one.

04

Why does a missing DKIM signature matter for on-premises mail?

Without DKIM, DMARC can only pass on SPF. That works until mail is forwarded, relayed or sent from an IP that is not in the SPF record, and then DMARC fails outright. Under RFC 9989, a message passes DMARC when SPF or DKIM passes for a domain aligned with the From address.

For a client on p=quarantine or p=reject, that single point of failure is a real delivery risk. Forwarded mail is the classic case: the forwarding server's IP is not in the client's SPF record, so SPF fails, and with no DKIM signature there is nothing left to pass DMARC. DMARC and email forwarding covers this in detail. Mailbox providers also expect DKIM. The UK's NCSC DKIM guidance says you should configure DKIM on domains you send email from, and recommends 2048-bit keys.

05

What are the options for DKIM with Exchange on-premises?

There are three realistic options, and the right one depends on whether the client already has a Microsoft 365 tenant or a gateway.

Option Who signs DKIM DNS record SPF change Best fit
Route outbound through Microsoft 365 (EOP) Microsoft 365, with the client's custom domain Two CNAMEs (selector1, selector2) pointing to Microsoft include:spf.protection.outlook.com; on-premises IPs can go once nothing sends directly Hybrid organisations and clients with a tenant
Outbound gateway or smarthost that signs The gateway, with the client's domain TXT or CNAME as the gateway specifies The gateway's include or IPs Clients that already route outbound through a secure email gateway
Third-party transport agent on Exchange The Exchange server itself TXT record with the public key you generate No change; on-premises IPs stay Fully on-premises clients with no cloud or gateway option

All three can produce an aligned DKIM pass. What differs is who holds the private key, how much the MSP has to maintain and how the message path changes.

06

How do you DKIM-sign on-premises mail through Microsoft 365?

Point the on-premises internet send connector at Exchange Online Protection as a smart host, make sure Microsoft 365 recognises the server through an inbound connector, then enable DKIM for the custom domain in Microsoft 365. Outbound mail then leaves through Microsoft's servers with a Microsoft 365 DKIM signature for the client's domain.

Step 1: understand the default hybrid route

In a hybrid organisation, on-premises senders do not use Microsoft 365 for internet mail by default. Microsoft's article on transport routing in Exchange hybrid deployments states that messages from senders in on-premises Exchange are always sent to internet recipients using DNS, whatever outbound routing option you choose in the Hybrid Configuration wizard. That wizard option, centralised mail transport, controls mail from Exchange Online senders, not on-premises ones. So enabling DKIM in the tenant alone does not sign mail from on-premises mailboxes.

Step 2: create a send connector that smart-hosts through EOP

Microsoft's guide to setting up connectors between Microsoft 365 and your own email servers gives the Exchange Management Shell command for a send connector that routes all internet mail to Microsoft 365 over certificate-validated TLS:

New-SendConnector -Name "My company to Office 365" -AddressSpaces * -CloudServicesMailEnabled $true -Fqdn mail.contoso.com -RequireTLS $true -DNSRoutingEnabled $false -SmartHosts contoso-com.mail.protection.outlook.com -TlsAuthLevel CertificateValidation

The smart host is the client's EOP endpoint, which takes the form <domain>-com.mail.protection.outlook.com. The -Fqdn value must match the certificate on the server. Disable or remove the old DNS-routed internet send connector once the new one is tested, otherwise Exchange may still pick it.

Step 3: make sure Microsoft 365 accepts the relay

Microsoft 365 needs an inbound connector from "Your organization's email server" so it knows the mail comes from the client. Microsoft recommends identifying the server by TLS certificate rather than IP address, and the certificate domain must be an accepted domain in the tenant. The certificate-based connector guide explains the settings. Hybrid organisations usually have this connector already from the Hybrid Configuration wizard; check that its certificate matches what the new send connector presents.

Since 1 November 2023, Exchange Online also requires the MAIL FROM domain or the certificate domain to be an accepted domain before it relays. Microsoft's updated SMTP relay requirements list the scenarios this affects, including on-premises bounce messages and applications that send with a non-accepted MAIL FROM domain.

Step 4: enable DKIM for the custom domain

In the Microsoft Defender portal, go to Email & collaboration > Policies & rules > Threat policies > Email authentication settings, open the DKIM tab, select the domain and turn on Sign messages for this domain with DKIM signatures. Before that works, publish the two CNAME records Microsoft shows for the domain:

selector1._domainkey.contoso.com  CNAME  selector1-contoso-com._domainkey.contoso.r-v1.dkim.mail.microsoft
selector2._domainkey.contoso.com  CNAME  selector2-contoso-com._domainkey.contoso.r-v1.dkim.mail.microsoft

The targets above are illustrative. Microsoft introduced a new target format for new custom domains in May 2025, while older domains keep the onmicrosoft.com format, so always copy the exact values from the portal or from Get-DkimSigningConfig. Without this step, Microsoft 365 signs only with the tenant's onmicrosoft.com domain, which does not align with the client's From domain.

Step 5: confirm with a real message

Send from an on-premises mailbox to an external test mailbox and read the headers. You want a DKIM-Signature header with d=contoso.com and Authentication-Results showing dkim=pass and dmarc=pass. Our email header analyzer shows the result, and how to read email headers explains the fields. Do not rely on the configuration alone: the header test is what proves the relayed mail is being signed with the client's domain.

07

What changes for SPF when mail routes through Microsoft 365?

Once internet mail leaves through EOP, receivers see Microsoft's IP addresses, so the SPF record needs include:spf.protection.outlook.com. The on-premises IPs can be removed when nothing sends directly any more. Microsoft's SPF configuration guide gives this example for a domain with an on-premises server:

v=spf1 ip4:192.168.0.10 include:spf.protection.outlook.com -all

Keep the ip4: entry during the change. Remove it only after DMARC aggregate reports show no more mail from the on-premises IP, because scanners, applications and backup routes often still send directly. Microsoft recommends -all for Microsoft 365 domains because DKIM and DMARC are also in place. If the record is near its limit, SPF too many DNS lookups explains how to stay under ten.

08

How does an outbound gateway or smarthost handle DKIM?

A secure email gateway or hosted smarthost can sign outbound mail with the client's domain, as long as you publish the gateway's public key in the client's DNS. Exchange relays all internet mail to the gateway, the gateway signs, and the signature aligns because d= is the client's domain.

The NCSC notes that DKIM signatures may be applied by your filtering service rather than your email server, and that a DKIM signature should be the last addition to a message before it is released. That matters here: Microsoft's own DKIM guide warns that Exchange 2016 and later can modify messages that flow through them. Sign at the last hop, after Exchange, disclaimers and signature tools have finished with the message, not before.

Check these points per gateway:

  • Signing domain: d= must be the client's domain or a subdomain of it, not the gateway vendor's domain. A vendor-domain signature passes DKIM but does not help DMARC.
  • Selector: use a selector unique to the gateway so it can be rotated without touching other senders. DKIM selectors explained covers naming.
  • SPF: add the gateway's include or IPs, since receivers now see the gateway as the sender.
  • Key length and rotation: 2048-bit where the gateway supports it, and a rotation plan. How to rotate DKIM keys safely gives the sequence.

Gateways also affect inbound authentication. How secure email gateways affect DMARC, SPF and DKIM covers both directions.

09

Should you use a third-party DKIM transport agent?

Only when routing through Microsoft 365 or a gateway is not possible. A transport agent signs on the Exchange server itself, so no mail flow changes, but the MSP takes on everything a cloud service would otherwise manage: generating and protecting the private key, publishing the public key and rotating it.

Microsoft's transport agent documentation sets some limits. The Transport service on Mailbox and Edge Transport servers supports the full agent SDK, the Front End Transport service supports only the SmtpReceiveAgent class, and the Mailbox Transport service does not support third-party agents at all. A signing agent therefore has to run in the right service and at the right point in the pipeline, after anything else that changes the message.

Before choosing this route, plan for:

  1. Testing after every update. Cumulative and security updates can affect transport agents. Recheck signing after each one.
  2. Key protection. The private key sits on the Exchange server, so its security depends on that server's patch level.
  3. Every outbound path. Each server that sends to the internet needs the agent, or some mail goes out unsigned.
  4. Supportability. The agent's vendor or maintainer, not Microsoft, supports the signing behaviour.

The DNS side is an ordinary DKIM TXT record you publish yourself:

exch2026._domainkey.contoso.com  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."

Check it with our DKIM validator after publishing.

10

Which option keeps DMARC aligned?

All three can, if the signing domain matches the client's From domain. RFC 9989 requires the DKIM d= domain to share the From domain's organisational domain (relaxed alignment) or match it exactly (strict alignment). The failure modes are specific to each option:

Option Typical alignment mistake How it shows in DMARC reports
Microsoft 365 DKIM not enabled for the custom domain, so only the onmicrosoft.com signature is applied dkim=pass for onmicrosoft.com, DMARC relies on SPF
Gateway Gateway signs with its own domain DKIM passes for the vendor domain, not aligned
Transport agent Message changed after signing, or one server missing the agent dkim=fail (body hash) or no signature from some IPs

DMARC alignment explained covers relaxed and strict alignment. Aggregate reports are the quickest way to see which on-premises IPs still send unsigned mail. On a DMARC AI tenant, you can ask the AI assistant which sources for a client domain lack an aligned DKIM pass, and it can check the live DNS records while answering.

11

Does the Exchange Server lifecycle change the decision?

It should be part of the conversation. Microsoft's Exchange Server supportability matrix states that Exchange Server 2016 and 2019 reached end of support on 14 October 2025. Exchange Server Subscription Edition follows the Modern Lifecycle Policy and has been available since July 2025.

A client still on 2016 or 2019 is running unsupported software for its mail. Routing outbound through Microsoft 365 solves DKIM now and is also a step towards moving mailboxes, so it rarely ends up as wasted work. A transport agent on an unsupported server is the option with the shortest useful life.

12

MSP checklist for clients still on Exchange on-premises

Use this for each client in the portfolio that still sends from its own Exchange servers:

  1. Record the version and support status: 2016, 2019 or SE, and the current update level.
  2. Map every outbound path: Exchange send connectors, relay connectors for scanners and applications, and any gateway. DMARC client discovery shows how to find them.
  3. Check whether outbound mail is signed today: send a test message and look for d= matching the client's domain.
  4. Pick the signing option: Microsoft 365 if there is a tenant, the gateway if one already handles outbound, a transport agent only as a last resort.
  5. Update SPF and connectors in order: add the new sender first, move the mail flow, then remove old IPs only when reports show they are idle.
  6. Verify the reverse DNS of any IP that still sends directly; reverse DNS and email authentication explains why.
  7. Watch DMARC reports for two to four weeks before tightening policy, then move from p=none to p=quarantine to p=reject as the reports stay clean.
  8. Document the key owner and rotation date per domain, so the next engineer knows where the key lives.

For the Microsoft 365 side of the same clients, see the DMARC for Microsoft 365 clients implementation guide. If a gateway also sits in front of the tenant for inbound mail, read why DMARC fails with a gateway in front of Microsoft 365 and the guide to Enhanced Filtering for Connectors.

13

FAQ

Can Exchange Server 2019 sign outbound email with DKIM?

No. Exchange Server 2019, like 2016 and Subscription Edition, has no built-in DKIM signing. Microsoft documents DKIM signing only for Microsoft 365. To sign on-premises mail, route it through Exchange Online Protection, through a gateway that signs with your domain, or install a third-party transport agent.

Does enabling DKIM in Microsoft 365 sign mail from on-premises mailboxes?

Not by default. In a hybrid setup, on-premises senders deliver internet mail directly through DNS. Only after you change the on-premises send connector to smart-host through Exchange Online Protection does that mail pass through Microsoft 365, where it can be signed. Confirm with a header test.

Can I export the Microsoft 365 DKIM key and use it on my Exchange server?

No. Microsoft 365 manages the private keys behind the selector CNAME records and does not let you export them. If on-premises mail must be signed without passing through Microsoft 365, generate a separate key pair with its own selector on the gateway or transport agent.

Do I need DKIM if SPF already passes for my Exchange server?

Yes, for any domain moving towards DMARC enforcement. SPF breaks on forwarding and many relays, and without DKIM there is no second aligned result to pass DMARC. Mailbox providers and the NCSC also expect DKIM on domains that send email, so treat it as required.

Can Microsoft 365 and a gateway both sign the same domain?

Yes, if each uses its own selector. Different systems can sign for one domain with different selectors and keys, because receivers look up the selector named in each signature. Make sure each message path is signed by the last system that touches it.

14

Final thoughts

The honest answer to "how do I set up DKIM on Exchange Server" is that you sign somewhere else. For most MSP clients that means Exchange Online Protection: one send connector, two CNAME records and a header test. Where a gateway already handles outbound mail, sign there. Keep transport agents for the cases where neither is possible, and use the DKIM work as the prompt for a platform conversation with any client still on Exchange 2016 or 2019.

Related articles

Related tools

Ready to Implement?

Get authenticated mail moving in minutes: start free, book a guided demo, or talk to the team about your stack.