> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://www.agentmail.to/docs/llms.txt.

# How do I avoid MX record conflicts?

If you already use Gmail, Outlook, or another email provider for your domain, adding AgentMail's MX records could conflict with your existing setup. Here is how to avoid that.

## Use a subdomain

The simplest and recommended approach: set up AgentMail on a subdomain instead of your root domain.

| Domain                   | Used by                     | No conflict         |
| ------------------------ | --------------------------- | ------------------- |
| `yourcompany.com`        | Gmail / Outlook (your team) | Unchanged           |
| `agents.yourcompany.com` | AgentMail (your agents)     | Separate MX records |

Your agents send and receive from addresses like `support@agents.yourcompany.com`, while your team keeps using `name@yourcompany.com`. Both work independently with no overlap.

## How to set it up

When adding your domain in AgentMail, use the subdomain:

**`TypeScript`**

```typescript title="TypeScript"
import { AgentMailClient } from "agentmail";

const client = new AgentMailClient({ apiKey: "am_..." });

// use a subdomain to avoid MX conflicts
const domain = await client.domains.create({ domain: "agents.yourcompany.com" });

// create inboxes on the subdomain
const inbox = await client.inboxes.create({
  username: "support",
  domain: "agents.yourcompany.com",
  displayName: "Support Agent",
});
// inbox address: support@agents.yourcompany.com
```

Then add the records AgentMail returns for `agents.yourcompany.com` at your DNS provider: the receiving MX, the MAIL FROM MX and SPF on `mail.agents.yourcompany.com`, DKIM, and DMARC. All of them sit on `agents.yourcompany.com` or names below it, so they are completely separate from your root domain's records and will not affect your existing email.

## Hosting inboxes on many subdomains

The setup above puts all your agents on one subdomain. If you instead want inboxes spread across **many** subdomains (for example, one per team or customer), [enable subdomains](/custom-domains#setting-up-subdomains) on the domain you registered. With them enabled on `agents.yourcompany.com`, publishing a single wildcard MX record (`*.agents.yourcompany.com`) lets you create inboxes on any nested subdomain, such as `support@team1.agents.yourcompany.com`, without registering each one. Your root domain's email is never touched.

## Can I use my root domain?

Yes. Pick the option that matches how you want mail to flow:

**Sending only (no receiving):** Create the domain with `inbound_enabled` set to `false`. AgentMail then leaves the receiving MX out of the records it returns, and registration skips the existing-provider check. You still add the MAIL FROM MX and SPF records on `mail.yourcompany.com`, plus the DKIM and DMARC TXT records. None of these change your root domain's MX records or its existing SPF record, so your Gmail or Outlook inbound mail is unaffected.

**`TypeScript`**

```typescript title="TypeScript"
// send-only: your existing provider keeps receiving mail
const domain = await client.domains.create({
  domain: "yourcompany.com",
  inboundEnabled: false,
});
```

> **Note**
>
> If `_dmarc.yourcompany.com` already has a DMARC record, keep that single record instead of adding a second one, and make sure it includes a `rua=mailto:` reporting address.

**Sending and receiving alongside Google Workspace:** Google stays the preferred mail server for your domain and a Google Workspace routing rule passes mail for unrecognized addresses to AgentMail. Register the domain with `allow_conflicting_provider` set to `true` and follow the [Google Workspace guide](/google-workspace). Without that flag, registering a domain whose MX records point to Google Workspace or Microsoft 365 returns a `422` error.

**AgentMail handles all inbound mail:** Replace your existing MX records with AgentMail's receiving MX. All incoming mail for the domain then routes to AgentMail instead of Gmail or Outlook. Only do this if you want AgentMail to handle all inbound email for that domain.

## Example DNS setup

**Before (Gmail only):**

```text
yourcompany.com                              MX     10    aspmx.l.google.com.
yourcompany.com                              MX     20    alt1.aspmx.l.google.com.
```

**After (Gmail on root + AgentMail on subdomain):**

```text
yourcompany.com                              MX     10    aspmx.l.google.com.
yourcompany.com                              MX     20    alt1.aspmx.l.google.com.
agents.yourcompany.com                       MX     10    inbound-smtp.us-east-1.amazonaws.com.
mail.agents.yourcompany.com                  MX     10    feedback-smtp.us-east-1.amazonses.com.
mail.agents.yourcompany.com                  TXT          "v=spf1 include:amazonses.com -all"
_dmarc.agents.yourcompany.com                TXT          "v=DMARC1; p=reject; rua=mailto:dmarc@agentmail.to"
selector._domainkey.agents.yourcompany.com   TXT          (DKIM value from AgentMail)
```

These are the values for a US-region domain. Copy the exact names and values AgentMail returns for your domain; see [the full record set](/knowledge-base/spf-dkim-dmarc#the-full-record-set) for what each record does.

> **Note**
>
> Legacy orgs should keep existing working DNS records in place. For new domain setup, add the TXT selector records shown in AgentMail.

Your team's email continues to flow through Gmail. Agent emails go through AgentMail. Clean separation with no conflicts.

## Common subdomain choices

| Subdomain                  | Example address                  |
| -------------------------- | -------------------------------- |
| `agents.yourcompany.com`   | `support@agents.yourcompany.com` |
| `outreach.yourcompany.com` | `sales@outreach.yourcompany.com` |
| `ai.yourcompany.com`       | `assistant@ai.yourcompany.com`   |

Pick whatever makes sense for your brand. The important thing is that it is a separate subdomain from your root domain's email. Avoid `mail.yourcompany.com` if you also register your root domain with AgentMail: that hostname is your root domain's MAIL FROM subdomain, and its only MX record must be AgentMail's bounce record.