---
title: Use provider-native features
description: Send a Postmark template, turn on SendGrid sandbox mode, or pick an SES configuration set per send without leaving the unified client.
lastModified: 2026-11-25
---

:::warning
The `native` send option is experimental. Its shape may change in a minor release while we collect feedback.
:::

The unified message covers what every provider shares. For features one provider has and others don't, such as stored templates, tracking toggles, unsubscribe groups, or test modes, pass `native` on the send. Its keys are adapter names:

```ts title="src/send-welcome.ts"
import { createEmailClient } from "@opencoredev/email-sdk";
import { postmark } from "@opencoredev/email-sdk/postmark";
import { resend } from "@opencoredev/email-sdk/resend";

const email = createEmailClient({
  adapters: [
    postmark({ serverToken: process.env.POSTMARK_SERVER_TOKEN! }),
    resend({ apiKey: process.env.RESEND_API_KEY! }),
  ],
  fallback: { adapters: ["resend"] },
});

await email.send(
  {
    from: "Acme <hello@acme.com>",
    to: "ada@example.com",
    subject: "Welcome to Acme",
    text: "Thanks for signing up.",
  },
  {
    native: {
      postmark: {
        template: {
          alias: "welcome",
          model: { name: "Ada" },
        },
        trackOpens: true,
      },
    },
  },
);
```

Postmark sends its stored `welcome` template. If the route falls back to Resend ([when that happens](/docs/concepts/fallbacks-and-retries)), Resend sends the inline subject and text, because there's no `resend` entry.

## How routing treats native options

- Each adapter that is tried receives only its own entry. Postmark options never reach Resend, and Resend options never reach Postmark.
- An adapter with no entry sends exactly what it would send without `native`.
- TypeScript infers the accepted keys from the adapters you passed to `createEmailClient`. An unknown key, a key for an adapter without native options (such as SMTP), or a field from another provider fails type checking.
- That check needs a literal name for every adapter, the same as `adapter` and `fallback` route names. An unnamed `smtp({ host })` written inside the `adapters` array gets the name type `string`, and the client then accepts any key. Pass `name: "smtp"` to keep the check.
- The SDK doesn't check the shape of native options at runtime. If a JavaScript caller passes the wrong shape, the provider's own API returns the error. The only runtime checks are that the `native` map and each entry in it are built from plain objects and arrays (a class instance throws an `EmailValidationError`), and the two rules below for the `body`, `fields`, and `headers` escape hatches.
- The SDK copies `native` when the send starts, and each adapter attempt gets its own copy of its entry. Changing an entry in middleware, a hook, or an adapter never changes your object, a retry, or the next adapter in the route.
- Existing code annotated with `EmailSendOptions<Name>` keeps compiling. That type has no `native` field; to pass native options through your own helper, type the parameter as `Parameters<typeof email.send>[1]`.

## Templates

The message still needs a `subject` and `html` or `text`. When you set a native template, the adapter sends the template in place of the inline body, and the inline fields stay the content for other adapters in the route.

- **Resend:** `template: { id, variables, useTemplateSubject }` replaces `html` and `text`. The message `subject` overrides the template's default subject; set `useTemplateSubject: true` to keep the template's.
- **Postmark:** `template: { id }` or `{ alias }`, plus `model` and `inlineCss`, sends to `/email/withTemplate` without `Subject`, `HtmlBody`, or `TextBody`.
- **SendGrid:** `templateId` and `dynamicTemplateData` replace `content`. Dynamic templates take their subject from the template.
- **SES:** `template: { name }` or `{ arn }`, plus `data`, replaces `Content.Simple`. Headers and attachments are still sent.
- **Mailgun:** `template: { name, version, variables, renderText }` replaces `html` and `text`. Mailgun still uses the message subject.
- **Brevo:** `templateId` and `params` replace `htmlContent` and `textContent`. The message `subject` overrides the template's subject; set `useTemplateSubject: true` to keep the template's.
- **Loops:** sends are always template-based. `transactionalId` overrides the adapter's `transactionalId` for this send, and `dataVariables` adds data variables.

With `sendPersonalized`, a SendGrid dynamic template gets each recipient's `variables` merged over `dynamicTemplateData` in that recipient's personalization.

## Other options by provider

Each adapter module exports its options type, for example `PostmarkNativeOptions` from `@opencoredev/email-sdk/postmark`.

- **Resend:** `topicId`
- **Postmark:** `messageStream` (overrides the adapter option), `trackOpens`, `trackLinks`, `tag`
- **SendGrid:** `asm` (`groupId`, `groupsToDisplay`), `ipPoolName`, `batchId`, `sandboxMode`, `tracking` (`clicks`, `opens`, `subscription`)
- **SES:** `configurationSetName` (overrides the adapter option), `listManagement` (`contactListName`, `topicName`), `feedbackForwardingEmailAddress`
- **Mailgun:** `tracking`, `trackingClicks`, `trackingOpens`, `testMode`, `requireTls`, `skipVerification`, `ipPool`
- **Brevo:** `batchId`
- **Loops:** `addToAudience`

Sandbox and test modes (`sendgrid.sandboxMode`, `mailgun.testMode`) make the provider validate the request without delivering it. The send still resolves successfully. `sendPersonalized` builds its `accepted` list from the recipients it submitted, so with either mode on that list names people who were validated, not sent to. Telemetry doesn't count these sends as provider volume. Both modes apply to that adapter alone: if the request fails and the route falls back, the next adapter sends for real, so leave fallback off for sandbox sends.

## Fields the SDK doesn't model

Resend, Postmark, SendGrid, SES, Brevo, and Loops accept two escape hatches in their entry, and so do Iterable, Mailchimp Transactional, MailerSend, MailPace, Mailtrap, Plunk, Scaleway, Sequenzy, SparkPost, Unosend, and ZeptoMail:

- `body` is shallow-merged over the request body the adapter builds. Its top-level keys replace the SDK's, so `body.mail_settings` replaces the whole object that `sandboxMode` would set.
- `headers` adds HTTP headers to the provider API request. These are not email headers; use `message.headers` for those. Native headers only add names. The send throws an `EmailValidationError` before calling the provider when a native header names, in any letter case, a header the adapter sets itself: its credentials, `Content-Type`, or a name from the adapter's own `headers` option. Resend also rejects `Idempotency-Key` on every send, even one without an `idempotencyKey`, because that option owns the header; pass `idempotencyKey` instead, which also gives each `sendPersonalized` recipient its own key. The same goes for `Content-Length`, `Transfer-Encoding`, and `Host`, which frame the request body. Mailgun's `Content-Type` carries the multipart boundary that fetch generates, and SES signs each request with SigV4, so SES also rejects `X-Amz-Date`, `X-Amz-Security-Token`, and `X-Amz-Content-Sha256`.

```ts title="src/send-mailersend-template.ts"
import { createEmailClient } from "@opencoredev/email-sdk";
import { mailersend } from "@opencoredev/email-sdk/mailersend";

const email = createEmailClient({
  adapters: [mailersend({ apiKey: process.env.MAILERSEND_API_KEY! })],
});

await email.send(
  {
    from: "Acme <hello@acme.com>",
    to: "ada@example.com",
    subject: "Welcome to Acme",
    text: "Thanks for signing up.",
  },
  {
    native: {
      mailersend: {
        body: { template_id: "zr6ke4n6kzon4eqy" },
        headers: { "X-Request-Id": crypto.randomUUID() },
      },
    },
  },
);
```

Mailgun sends multipart form data, so its escape hatch is `fields` instead of `body`. Each field replaces the SDK's value for that name, and an array value appends one field per item: `fields: { "o:dkim": "no" }`.

`sendPersonalized` rejects `body` and `fields` with an `EmailValidationError` before anything is sent. Either one can replace the recipients, such as SendGrid's `personalizations` or Mailgun's `to`, and the result's `accepted` list would then name people the provider never received. Typed options and `headers` still work in personalized sends. To use `body` or `fields`, call `send()` for each recipient.

A `send()` with `body` or `fields` doesn't count the message's recipients as submitted in telemetry, since the passthrough may have replaced them.

SMTP, Cloudflare, Microsoft Graph, Helo, Sendheron, JetEmail, Primitive, Lettermint, and Lettr don't take native options yet.

## Batches

`sendMany` takes `native` both on the batch options and on each item. An item's entry for an adapter replaces the batch entry for that adapter. Entries for other adapters still come from the batch.

```ts
await email.sendMany(
  [
    { message: first },
    { message: second, options: { native: { postmark: { tag: "vip" } } } },
  ],
  { native: { postmark: { messageStream: "broadcast" } } },
);
```

The second item's Postmark entry is `{ tag: "vip" }` only, so it uses the adapter's default stream.

## Native options on a custom adapter

Declare the options type as the fourth type argument of `EmailAdapter`, and read it from `context.native`. Use a type alias, not an interface, so it fits the JSON-compatible constraint.

```ts title="src/acme-adapter.ts"
import type { EmailAdapter } from "@opencoredev/email-sdk";

type AcmeNativeOptions = { priority?: "high" | "low" };

export const acme: EmailAdapter<"acme", unknown, unknown, AcmeNativeOptions> = {
  name: "acme",
  capabilities: {
    repeatedHeaders: true,
    idempotency: "none",
    scheduling: false,
    personalized: "expanded",
  },
  async send(message, context) {
    const priority = context.native?.priority ?? "low";
    // Call the Acme API with `priority`.
    return { adapter: "acme" };
  },
};
```

**[Fallbacks and retries](/docs/concepts/fallbacks-and-retries)**

How a route moves from one adapter to the next.

**[Adapter contract](/docs/reference/adapter-contract)**

The full EmailAdapter type and context.
