Integrating · Published 2026-11-27 · Updated 2026-11-27 · AgentiSend
Send email from Craft CMS
Craft CMS sends email with the AgentiSend mail adapter. Settings, Email, Test posts that message to POST /emails.
Settings → Email → Test posts that one message to POST /emails. /docs/guides/craft.
Install
The package name is agentisend/craft. It requires Craft CMS 5.3 or newer.
composer require agentisend/craft
php craft plugin/install agentisendOpen Settings → Email. Set Transport Type to AgentiSend. Paste an API key from POST /api-keys, and a From email on a domain you have verified. From name is optional. Leave API host blank. Save.
Nothing is sent until that save. Installing the plugin does not call the API, and an empty key does not call it either.
The From email on the adapter is the address on the message. Craft's own From field on the same page is not the one that is posted.
What Save checks
Save calls GET /domains with the key. The From domain has to be on that list as verified, or partially verified, with sending enabled. A key that is not allowed to list domains is checked with POST /emails/preflight instead, to domain-check@example.com, and that call does not send. If the key is refused, or the domain is not verified, the settings are not stored. The sentence on the field is the code, the message, and the fix.
invalid_api_key means "API key is invalid or revoked." The fix is "Create a new key with POST /api-keys; deleted keys cannot be restored."
domain_not_verified means "This sending domain is not verified." The fix is "If it is pending, publish the required records from GET /domains/:id; checks continue for 72 hours. Test now by sending to an address ending in @simulator.agentisend.com. If it is not registered, POST /domains first. If it is failed, GET /domains/:id names the record to fix, then POST /domains/:id/verify to reopen the window."
restricted_api_key means "This API key is restricted to sending only." The fix is "Use a full_access key (POST /api-keys with permission=full_access) for management endpoints." A sending-only key can still be saved when the preflight says the domain is verified.
domain_sending_disabled means "Sending is turned off for this domain." The fix is "Turn it back on with PATCH /domains/:id and {"capabilities": {"sending": "enabled"}}, or send from another domain."
Send with Test
The Test button on Settings → Email is Craft's own button. It posts one message to POST /emails. The Idempotency-Key is that message's id, so a repeat of the same message returns the original id.
The notice shows the success sentence when the send is accepted. When the send is refused, the notice is the code, the message, and the fix. GET /emails/{id} reads the message back.
A rehearsal goes to an address ending in @simulator.agentisend.com. Those addresses and what each one does are on Test addresses.
curl -sS -X POST https://api.agentisend.com/emails \
-H "Authorization: Bearer $AGENTISEND_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"from":"billing@yourdomain.com","to":"delivered@simulator.agentisend.com","subject":"Your receipt","text":"Thanks — the details are attached."}'201
{
"id": "9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42",
"simulated": true,
"warnings": []
}curl -sS -X GET https://api.agentisend.com/emails/9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42 \
-H "Authorization: Bearer $AGENTISEND_API_KEY"200
{
"api_key_id": "example",
"attachments": [],
"bcc": [],
"cc": [],
"created_at": "2026-09-04T09:14:00.000Z",
"domain": "example",
"from": "example",
"headers": {},
"html": "example",
"id": "9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42",
"last_event": "queued",
"message_id": "example",
"object": "email",
"provider_message_id": "example",
"reply_to": [],
"scheduled_at": "2026-09-04T09:14:00.000Z",
"status": "queued",
"subject": "example",
"tags": {},
"template_id": "9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42",
"template_version": -9007199254740991,
"text": "example",
"to": [],
"updated_at": "2026-09-04T09:14:00.000Z",
"warnings": []
}Remove the plugin
php craft plugin/uninstall agentisendUninstall deletes the saved key and sets the transport back to Craft's default. It does not call the API.
Troubleshooting
| What you see | What to do |
|---|---|
invalid_api_key on save | Create a new key with POST /api-keys. A deleted key cannot be restored. |
missing_api_key | Paste the key into the adapter and save. The plugin does not send without one. |
domain_not_verified | Publish the records from GET /domains/{id}, or send a test to an address ending in @simulator.agentisend.com while the domain is still pending. The domain records are on Domains and DNS. |
domain_sending_disabled | Turn sending back on with PATCH /domains/{id} and {"capabilities": {"sending": "enabled"}}, or send from another domain. |
Test says the code and a fix | The fix is the next step. Test again after you have done it. |