Get an API key
Domain

mail.enable()

domain.mail.enable({ subdomain?, replace? }) → Promise<Mail>

Poses everything mail needs in one call: routing, the sender policy, the signing key and the alignment policy. On the apex, or on a subdomain when the apex already receives elsewhere.

four records, one callrefuses to replace live mailthe key is reused
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

await domain.mail.enable();                         // addresses at @example.com
await domain.mail.enable({ subdomain: "team" });    // at @team.example.com, apex untouched
await domain.mail.enable({ replace: true });        // replace live mail servers — deliberate
domain.mail.enable()                      # addresses at @example.com
domain.mail.enable(subdomain="team")      # at @team.example.com, apex untouched
domain.mail.enable(replace=True)          # replace live mail servers — deliberate

Live mail is never replaced without being asked

mail_would_replace_mx, with the current servers attached

Posing ours over a working configuration stops the customer receiving at the second it takes effect, and they find out at the first lost message. The refusal carries details.current — show it, and offer the two ways out.

import { IaGenifyError } from "iagenify";

try {
  await domain.mail.enable();
} catch (err) {
  if (err instanceof IaGenifyError && err.code === "mail_would_replace_mx") {
    console.log("mail currently goes to:", err.details.current);
    await domain.mail.enable({ subdomain: "team" });   // or { replace: true }
  }
}
from iagenify import IaGenifyError

try:
    domain.mail.enable()
except IaGenifyError as error:
    if error.code != "mail_would_replace_mx":
        raise
    print("mail currently goes to:", error.details["current"])
    domain.mail.enable(subdomain="team")   # or replace=True

Both domains most people attach already receive mail somewhere. This is the normal case, not the edge case.

Returns

{
  host: "team.example.com", subdomain: "team",
  mx: [{ name, content, priority }],
  spf: "…", dkim: { selector, publicKey }, dmarc: "…",
  posed: [...], replaced: [...], failed: [...],
  dns: { mxOk, spfOk, dkimOk, dmarcOk },
  ready: true,
}
{
    "host": "team.example.com", "subdomain": "team",
    "mx": [{"name": ..., "content": ..., "priority": ...}],
    "spf": "…", "dkim": {"selector": ..., "publicKey": ...}, "dmarc": "…",
    "posed": [...], "replaced": [...], "failed": [...],
    "dns": {"mxOk": ..., "spfOk": ..., "dkimOk": ..., "dmarcOk": ...},
    "ready": True,
}

failed is the one to read: a record that did not land means mail that will not work, and calling again poses only what is missing.

A host, not a domain

The apex and each subdomain are configured separately, each with its own records, key and policy — a policy on the apex does not cover a subdomain. Both coexist.

Calling it twice poses nothing

It writes what is missing. A second call on a configured host changes nothing, which makes it safe to run from an interface.

What is posed, and why

  • A strict sender policy — a soft one lets spoofing through.
  • The sender list points at a name of ours, so the relay can change without touching a customer's zone.
  • A 2048-bit signing key, with no test flag.
  • An observing policy first: a strict one breaks mailing lists before anyone has looked at a report.