> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailchannels.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send email from Airtable with MailChannels

> Use the MailChannels Email for Airtable extension to email the address in each selected record, or send from a Run a script automation.

The MailChannels Email for Airtable extension sends an email to the address in each selected record, using a subject and message you write once. A **Run a script** automation can send the same email when a record changes.

> [!NOTE]
>
> The extension will be available in the Airtable Marketplace once Airtable approves it.

## What you need before you start

* A **MailChannels account** and an API key. [Sign up](https://www.mailchannels.com/pricing/#for_devs) if you don't have one.
* A **sending domain** authorized with [Domain Lockdown](https://docs.mailchannels.com/email-api/domain-lockdown.md).
* **Editor or creator** access to the base.
* On Airtable **Enterprise** plans, an admin must allow third-party extensions that connect to non-Airtable servers.

## Set up the extension

**1. Connect to MailChannels**

1. Add the extension to a base dashboard.
2. Click **Connect to MailChannels**. Sign in with your MailChannels API key, then allow access to the base when Airtable asks.
3. Return to the extension and click **Continue**.

MailChannels reads only the records you send and checks that you can edit the base. Your API key and the Airtable token stay on MailChannels' servers, never in the base.

**2. Set up the email**

Choose the table, the field that holds each recipient's email address, the sender, a subject and the message. The sender must use your authorized domain.

Write `{Field name}` to insert a value from the record, for example `Hello {Name}`. Renaming a field later keeps the template working.

**3. Preview and send**

Select records, click **Preview** to check the emails, then click **Send**.

Each record shows its own result: accepted, rejected, or not sent with the reason, for example an empty email field. If a send stops with an error, **Retry the same send** finishes it without emailing anyone twice.

## Send from an automation

Run a script isn't available on Airtable's Free plan or Team trials, so this needs a paid plan.

1. In the extension's setup, enter the automation's workflow ID (it starts with `wfl`) and save. Copy the credential it shows. It appears only once.
2. In the automation, add an Airtable secret named `MailChannels credential` that holds the credential.
3. Add a **Run a script** action and paste the script below.
4. Set the script's input variables: `recordId`, `workflowId`, `templateId` (`default`) and `operationKey`.

The operation key must stay the same when a run repeats, and change for a deliberate new send. A formula that joins `RECORD_ID()` with the time the send was requested works. A repeated key never sends twice.

```javascript Run a script action theme={null}
// MailChannels for Airtable: Run-a-script automation action. Paste this file unchanged into the action.
// Input variables: recordId, workflowId (wfl..., from the automation URL), templateId and operationKey.
// Secret: "MailChannels credential". Referencing it locks script editing to users who can access that secret.
// The run fails unless MailChannels accepted the message; it never retries.
const ENDPOINT = 'https://integrations.mailchannels.net/airtable/automation/send';

const config = input.config();
for (const name of ['recordId', 'workflowId', 'templateId', 'operationKey']) {
  if (typeof config[name] !== 'string' || config[name].length === 0) throw new Error(`Missing input variable: ${name}`);
}
const response = await fetch(ENDPOINT, {
  method: 'POST',
  headers: { 'content-type': 'application/json', authorization: `Bearer ${input.secret('MailChannels credential')}` },
  body: JSON.stringify({
    base_id: base.id, workflow_id: config.workflowId, template_id: config.templateId,
    record_id: config.recordId, operation_key: config.operationKey
  })
});
let body = null;
try { body = await response.json(); } catch { /* Non-JSON responses are reported by status below. */ }
const result = response.status === 200 && Array.isArray(body?.results) ? body.results[0] : null;
const state = typeof result?.state === 'string' ? result.state : 'not-sent';
output.set('state', state);
output.set('duplicate', result?.duplicate === true);
const refusal = { 401: 'reauthorize', 403: 'denied', 503: 'retry_later' }[response.status] ?? `http-${response.status}`;
output.set('reason', result ? (typeof result.reason === 'string' ? result.reason : '') : refusal);
if (state !== 'accepted') throw new Error(`MailChannels send ${state}; see the outputs. Do not change operationKey to retry an unknown result.`);
```

The action fails unless MailChannels accepted the message, and it doesn't retry. If a run reports an unknown result, don't change the operation key to try again.

## Get help

Email [support@mailchannels.com](mailto:support@mailchannels.com). Include the base ID and the time of the send. Never include your API key.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.