Getting Started with Mailtarget + OpenClaw

Send your first email in under 5 minutes.

Prerequisites

Step 1: Install the Skill

clawhub install mailtarget-email

Step 2: Get Your API Key

  1. Log in to app.mailtarget.co
  2. Go to Settings → API Keys
  3. Click Create API Key
  4. Copy the key

Step 3: Configure OpenClaw

Add your API key to the OpenClaw gateway environment:

openclaw env set MAILTARGET_API_KEY=your_api_key_here

Or export it in your shell:

export MAILTARGET_API_KEY=your_api_key_here

Step 4: Send Your First Email

Just tell your agent:

"Send a test email to hello@example.com from noreply@mydomain.com with the subject 'Hello from OpenClaw' and a simple welcome message."

The agent handles the rest — writing the HTML, calling the API, confirming delivery.

Step 5: Try More

Here are things you can ask your agent to do:


Autonomous Domain Setup (SPF / DKIM / DMARC)

🚀 Zero Manual DNS Editing

If your domain is on Cloudflare, the agent can set up email authentication entirely by itself. No DNS dashboard required.

What You Need

Configure the Cloudflare credentials:

openclaw env set CLOUDFLARE_API_TOKEN=your_token_here
openclaw env set CLOUDFLARE_ZONE_ID=your_zone_id_here

Just Tell Your Agent

"Set up example.com as a sending domain in Mailtarget with full email authentication."

What the Agent Does

  1. Creates the sending domain in Mailtarget
  2. Reads the required DNS records — SPF value, DKIM selector & key, CNAME for tracking
  3. Adds SPF TXT record in Cloudflare (or merges into existing SPF)
  4. Adds DKIM TXT record in Cloudflare
  5. Adds CNAME record for click/open tracking
  6. Verifies the domain in Mailtarget
  7. Confirms all records pass verification

The entire process takes about 30 seconds. Fully autonomous.

For Non-Cloudflare Domains

The agent will still create the domain and read the required DNS values. It will then provide you with the exact records to add manually:

After you add them, tell the agent to verify.


What's Happening Under the Hood

You (vision) → OpenClaw Agent (execution) → Mailtarget API (delivery)

Tracking & Events

Enable open and click tracking by telling your agent:

"Send the email with open tracking and click tracking enabled."

The agent sets openTracking: true and clickTracking: true in the API call. Mailtarget fires webhook events for opens, clicks, bounces, and deliveries.

Troubleshooting

ProblemFix
401 UnauthorizedCheck your API key is correct and active
400 Bad RequestVerify the from email uses a verified sending domain
Email not arrivingCheck spam folder; verify SPF/DKIM records for your domain
MAILTARGET_API_KEY not foundEnsure the env var is set in the gateway environment
Domain verification failsDNS propagation can take up to 5 minutes — tell the agent to retry

Resources