Prerequisites
OpenClaw installed and running
A Mailtarget account with API access
A company domain you own (e.g.
yourcompany.com)
⚠️ Company Domain Required
You must use your own company domain to send emails (e.g. [email protected]). Free email domains like Gmail, Yahoo, Outlook, or any public email provider are not allowed as sending addresses.
Your domain can be hosted on any provider — Google Workspace, Microsoft 365, Cloudflare, or any DNS host. As long as you own the domain and can configure its DNS records, you're good to go.
💡 We strongly recommend using a subdomain (e.g. mail.yourcompany.com or notifications.yourcompany.com) or a new dedicated domain for sending. This keeps your main domain's reputation isolated and gives you a safe environment for testing without affecting your existing email setup.
Step 1: Install the Skill
clawhub install mailtarget-email
ds
Step 2: Get Your API Key
Log in to app.mailtarget.co
Go to Settings → API Keys
Click Create API Key
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 [email protected] from [email protected] 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:
"Send a campaign to these 50 contacts with personalized greetings" — uses substitution data
"Create an HTML email template for our weekly newsletter" — stores it via the Template API
"List our sending domains and check which ones are verified" — domain management
"Send a transactional receipt email with a PDF attachment" — attachments + transactional flag
Autonomous Domain Setup (SPF / DKIM / DMARC)
🚀 Zero Manual DNS Editing
If your company domain is on Cloudflare, the agent can set up email authentication entirely by itself. No DNS dashboard required.
What You Need
Mailtarget API key (from Step 2 above)
Your company domain (e.g.
yourcompany.com) — must be a domain you ownCloudflare API token with DNS Write permission (create one here)
Your Cloudflare Zone ID (found on the domain overview page)
Install the companion skill and configure credentials:
clawhub install spf-dkim-setup 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 yourcompany.com as a sending domain in Mailtarget with full email authentication."
What the Agent Does
Creates the sending domain in Mailtarget
Reads the required DNS records, SPF value, DKIM selector & key, CNAME for tracking
Adds SPF TXT record in Cloudflare (or merges into existing SPF)
Adds DKIM TXT record in Cloudflare
Adds CNAME record for click/open tracking
Verifies the domain in Mailtarget
Confirms all records pass verification
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 in your DNS provider (Google Domains, Microsoft 365 admin, Route53, etc.):
SPF TXT record, hostname and value
DKIM TXT record, selector hostname and public key
CNAME record, tracking domain
After you add them, tell the agent to verify.
What's Happening Under the Hood
You decide what to send and who to send it to
OpenClaw writes the content, builds the HTML, sets up domains, calls the API
Mailtarget handles delivery, authentication (SPF/DKIM/DMARC), tracking, and reliability
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
Problem | Fix |
401 Unauthorized | Check your API key is correct and active |
400 Bad Request | Verify the |
Email not arriving | Check spam folder; verify SPF/DKIM records for your domain |
| Ensure the env var is set in the gateway environment |
Domain verification fails | DNS propagation can take up to 5 minutes, tell the agent to retry |
Free email domain rejected | Use your company domain, Gmail, Yahoo, Outlook, etc. are not allowed as sender addresses |
Resources

