Skip to content

Give your agent an address on your own domain, such as agent@mail.example.com. You connect the domain, publish the DNS records Photon shows you, and send a first email to the agent.

Prerequisites

You need:

  • A project from Set up your project.
  • A domain you control, and access to edit its DNS records.
  • A separate inbox to send test email from.
1

Connect your domain

Open Email in your project. Under Connect a domain, enter the domain or subdomain and select Connect domain. Enter only the domain, without https:// or an email address.

Connect your own domain or an unused subdomain. Sample data.
Connect the domain with code instead

This replaces Connect domain in the dashboard; don't do both. Your API key needs platforms:write to connect the domain and platforms:read to poll its operation. Generate a unique setup key for this attempt:

Code
export PHOTON_EMAIL_DOMAIN="mail.example.com"
export PHOTON_SETUP_KEY="first-agent-email-$(date +%s)"

Save the generated PHOTON_SETUP_KEY. If the result is uncertain, rerun only the setup program with the same domain and saved key. A new timestamp starts a new attempt, not a retry.

Save the example as setup.ts, setup.py, src/main.rs, or main.go in the directory you prepared in project setup.

import { Photon } from "@photon-ai/api";

const required = (name: string): string => {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name}`);
  return value;
};

const photon = new Photon({
  headers: { Authorization: `Bearer ${required("PHOTON_API_KEY")}` },
});
try {
  const operation = await photon.projects.platforms.connectEmailDomain({
    path: { id: required("PHOTON_PROJECT_ID") },
    headers: { idempotencyKey: required("PHOTON_SETUP_KEY") },
    body: { domain: required("PHOTON_EMAIL_DOMAIN") },
  });
  console.log(operation.operationId);
} catch {
  console.error("Could not connect the domain. Check the key, permissions, and domain name.");
  process.exitCode = 1;
}
node setup.ts

The program prints an operation ID. Return to Email and open the domain to publish its DNS records.

2

Publish the DNS records

Open the domain's setup page. At your DNS provider, add every record Photon shows, with the same type, host, value, and MX priority. The values are specific to your domain; don't copy them from this image.

The setup page checks both sending and receiving records. Sample data.
RecordWhat it does
DKIM CNAMEVerifies your domain and signs the email your agent sends.
Bounce MX and SPF TXTSet the return path for delivery failures.
Receiving MXRoutes incoming email for the domain to Photon. The domain doesn't connect without it.

Each MX record must be the only MX record at its host. If your DNS provider appends the zone name to hosts, enter the host without the domain. If it offers a proxy for CNAME records, choose DNS only.

3

Wait for Connected

Photon checks your DNS automatically. Wait until the domain shows Connected and the verification checks pass. DNS changes can take a while to spread; reloading the page doesn't speed them up. Photon waits up to 72 hours per verification stage. If verification fails or times out, fix the records and connect the domain again. If you use the API, use a new idempotency key. See Domains for the records and errors.

4

Email your agent

Pick any address at exactly the connected domain, such as agent@mail.example.com. A subdomain of the connected domain is not covered. You don't create a mailbox first: Photon resolves the receiving address when the first email arrives.

From your separate inbox, send a plain-text email to that address. Then open the domain in Email and select Inbox. Your email appears there.

If your email doesn't arrive

What you seeWhat to check
The domain stays Waiting for DNSCompare every record with your DNS provider: a doubled domain in the host, MX priorities, or a proxied CNAME. Then give DNS time to update.
The domain is Connected, but no email arrivesCheck that you emailed the exact connected domain, not a subdomain of it. Photon drops mail to a domain that isn't connected without creating a Message.
Email arrives in the inbox, but not in your code laterThe API key belongs to another project, or lacks project:read.

Next: receive messages

For HTML bodies, attachments, recipients, delivery events, sending limits and errors, see Email.

Receive messages

Get each email to your agent as an event in your code.