Skip to content
Browse the docs

Frameworks and agents · Published 2026-11-24 · Updated 2026-11-27 · AgentiSend

Send email from Drupal

The AgentiSend module posts Drupal mail to POST /emails after you save a key and a From address.

Drupal integration page

Install the module, open Configuration → System → AgentiSend, and save an API key plus a From address on a domain you have verified. Registration mail and password reset mail then go to POST /emails. Nothing is sent before that save.

GET /emails/{id} reads a message back. POST /api-keys creates the key.

Install

The module needs the agentisend/symfony-mailer package, which Composer installs from Packagist. The module is being published on drupal.org as project agentisend. Until its first release is listed there, the line below does not resolve:

composer require drupal/agentisend

Enable AgentiSend. The settings form is the only setup screen.

Saving a key calls GET /domains. The From domain has to be 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 values you just typed are not stored. The sentence on the screen is the code, the message and the fix.

Send a test posts one message to delivered@simulator.agentisend.com. The button does not call the API until a key has been saved.

Uninstall deletes the saved key. If the module had taken over sending, the previous mail plugin is put back. Uninstall does not call the API.

What core does

The plugin id is symfony_mailer. Its getMailer() reads system.mail mailer_dsn and calls Transport::getDefaultFactories(). Installing the Composer package does not register the factory. The module's hook_mail_backend_info_alter points that plugin at a subclass that prepends the factory, so scheme agentisend+api resolves. agentisend is the same scheme.

The experimental mailer collects the mailer.transport_factory tag. The module tags AgentiSend\SymfonyMailer\Transport\AgentiSendTransportFactory with that tag. On a Drupal 11 release that does not ship that collector, the tag is unused and the plugin subclass is what makes mailer_dsn work.

When the site is still on PHP mail, saving a key selects the module's own mail plugin instead. That plugin maps the Drupal message to POST /emails. hook_mail_alter sets the From address. With no key saved, the hook returns without changing the message.

settings.php

Sites that already set the core mailer can keep doing that. The module registers the factory either way:

$config['system.mail']['interface']['default'] = 'symfony_mailer';
$config['system.mail']['mailer_dsn'] = [
  'scheme' => 'agentisend+api',
  'host' => 'default',
  'user' => 'as_your_key',
  'password' => null,
  'port' => null,
  'options' => [],
];

Host default is https://api.agentisend.com. A local server is options base_url set to that server's origin.

What is posted

The transport posts the message to POST /emails. A refusal carries code, message and fix. The error catalogue lists every code. The Symfony guide is the same DSN.

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": []
}
Response
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": []
}
Response
curl -sS -X POST https://api.agentisend.com/api-keys \
  -H "Authorization: Bearer $AGENTISEND_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name":"example","permission":"full_access"}'
201
{
  "budget_per_period": 5000,
  "created_at": "2026-09-04T09:14:00.000Z",
  "domain_scope": "example",
  "expires_at": "2026-09-04T09:14:00.000Z",
  "id": "9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42",
  "last_used_at": "2026-09-04T09:14:00.000Z",
  "loop_guard": "off",
  "name": "example",
  "object": "api_key",
  "period": "monthly",
  "permission": "full_access",
  "previous_key_expires_at": "2026-09-04T09:14:00.000Z",
  "rate_ceiling_per_minute": 600,
  "request_count_30d": -9007199254740991,
  "rotated_at": "2026-09-04T09:14:00.000Z",
  "scopes": [],
  "system": false,
  "token": "as_abababababababababababababababababababababababababababababababab",
  "token_prefix": "as_abababab"
}
Response

Next