Skip to main content

Third-party mail gateway

Normally mail moves directly in and out of your mail server: external senders deliver to us, and we deliver your outgoing mail to each recipient.

A third-party mail gateway puts an external service into that path: an anti-spam appliance, a compliance or archiving filter, or a smarthost your organization must send through.

An optional, advanced feature

If you have no such service, leave both gateways off. The direct path is right for almost everyone.

Set up a gateway on the Mail service page: open Services, select the zone, then the domain's Mail service. The two directions are independent; turn on one, both, or neither. A small Mail Flow diagram shows the resulting path and updates live as you change the switch.

For a complete setup with a named provider, where the gateway settings are one step among several, see Third-party integrations.

The incoming gateway​

Use this when an external MX must sit in front of our mail server. Incoming mail arrives at the gateway first, which filters it and passes the clean mail to us.

FieldWhat it is
Gateway MX RecordsOne per line, as <priority> <hostname>; a lower number comes first. These become the domain's public MX records, so external senders deliver to the gateway, not to us.
Gateway Source AddressesThe IP addresses or hostnames the gateway forwards the filtered mail from. We refuse incoming mail from any other source.
Don't leave Gateway Source Addresses empty

Refusing other sources is the point of the gateway: it stops a spammer from bypassing the gateway and reaching us directly. With the field empty, we accept mail from anywhere and the gateway loses most of its value.

The panel warns you when the gateway is on and no source addresses are set. Fill in the gateway's exit IP addresses unless you have a specific reason not to.

The outgoing gateway​

Use this when the domain's outgoing mail must go through an external smarthost or compliance gateway instead of directly to each recipient.

FieldWhat it is
Gateway Destination AddressesThe IP addresses or hostnames we deliver outgoing mail to. With more than one, we try them in order; later ones are fallbacks.
SMTP Authentication (SASL Username / Password)Optional. Set both if the gateway asks us to authenticate; leave them empty if it trusts us by IP address.
Client CertificateOptional. One of your hosts whose certificate we show the gateway when we connect, for a gateway that recognizes its senders by certificate. Leave it at None if the gateway knows us by IP address or by SMTP authentication. See below.

Your mail now leaves from the gateway's servers, so the gateway's authentication records must be in place for receivers to keep trusting it:

FieldWhat it does
Gateway SPF RecordThe full SPF value from the provider. It replaces the generated SPF record in the published TXT record, authorizing the gateway's servers to send for your domain.
Gateway DKIM Selector and Gateway DKIM RecordThe provider's DKIM key. The panel publishes it beside our own DKIM records, at <selector>._domainkey.<domain>, so the gateway can sign your outgoing mail and DKIM keeps passing.

A gateway that recognizes you by certificate​

Some gateways don't accept a sender because of its IP address, since our address is shared with other customers. They want the sending server to prove which organization it belongs to with a TLS certificate instead. Microsoft 365's inbound connector is the common case (Microsoft 365 hybrid).

For those, choose a Client Certificate: one of your own hosts that has a certificate. The list puts the domain's mail host (mail.<domain>) first; it's usually the right choice. Any other of your hosts works too, for example when the gateway expects a certificate under a different domain of yours.

We then show that host's certificate to the gateway, and only to it, when we deliver the domain's outgoing mail. The certificate is renewed automatically, and the gateway sees the new one from then on. With a client certificate set, we deliver to the gateway only over an encrypted connection: mail waits in the queue rather than go to it unencrypted.

After you save, the Third-Party Outgoing Mail Gateway card on the Mail Routing tab shows two more things:

EntryWhat it tells you
Client CertificateThe host, and whether its certificate is Usable: issued by a certificate authority, not expired, and covering the host's name. A new host first has a temporary self-signed certificate; the card says Not usable yet until the real one is issued, usually within minutes.
Certificate Name for the GatewayThe name to give the gateway as the certificate it should expect: the host's name with its first part replaced by *, for example *.example.com for mail.example.com. For a host like example.com it's the name itself.
A certificate that isn't usable gets your mail refused

A gateway that checks the certificate refuses mail sent with a temporary or expired one, and the mail comes back to its sender as undeliverable. Wait until the card says Usable before you switch the gateway's side to require it.

Turning the outgoing gateway off, or choosing None, stops us from showing the certificate. If the chosen host is removed, the gateway goes on without a certificate, as with None.

The panel handles DNS for you​

Turning on a gateway changes the published records:

  • the incoming gateway puts its MX records in place
  • the outgoing gateway puts its SPF record in place and adds its DKIM record

As always, you don't edit DNS by hand. The Generated DNS Records section of the Mail service page shows the new values after you save. See DNS is managed for you.

If mail authentication starts failing after you turn on an outgoing gateway

The usual cause is a missing or wrong gateway SPF or DKIM value. Check both against what the provider gave you. Sender verification explains what each record proves.