# MailerSend (/docs/v/0.6.1/adapters/mailersend)



The MailerSend adapter calls the [MailerSend Email API](https://developers.mailersend.com/api/v1/email.html) over `fetch` — no extra dependency. Its quirk: MailerSend accepts exactly one reply-to address, and the message id comes back in the `x-message-id` response header rather than the body.

<ProviderBadge adapter="mailersend" />

## Configure [#configure]

Create an API token in the [MailerSend dashboard](https://app.mailersend.com/api-tokens) and verify the domain you plan to send from.

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

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

<TypeTable
  type="{
  apiKey: {
    description: &#x22;MailerSend API token, sent as a Bearer header.&#x22;,
    type: &#x22;string&#x22;,
    required: true,
  },
  baseUrl: {
    description: &#x22;Override the API origin, e.g. for a proxy.&#x22;,
    type: &#x22;string&#x22;,
    default: '&#x22;https://api.mailersend.com&#x22;',
  },
  fetch: {
    description: &#x22;Custom fetch implementation for tests or special runtimes.&#x22;,
    type: &#x22;typeof fetch&#x22;,
  },
}"
/>

## Send [#send]

MailerSend maps `cc`, `bcc`, `headers`, `attachments` (an attachment's `contentId` becomes MailerSend's `id`), and `tags` (values only). `replyTo` accepts a single address — two or more throw an `EmailValidationError` before any request.

```ts
const result = await email.send({
  from: "Acme <hello@acme.com>",
  to: [{ email: "user@example.com", name: "Ada" }],
  replyTo: "support@acme.com",
  subject: "Reset your Acme password",
  html: "<p>Click the link below to choose a new password.</p>",
  tags: [{ name: "type", value: "password-reset" }],
});

console.log(result.id); // MailerSend message id from the x-message-id header
```

The response `id` comes from the `x-message-id` response header, falling back to `message_id` or `id` in the body — use it to look the send up in MailerSend's activity log.

<Callout type="warn" title="No metadata field">
  MailerSend has no metadata concept, so `metadata` on a message throws an
  `EmailValidationError` before any request is made. Use `tags` instead, or pick a
  [metadata-capable adapter](/docs/v/0.6.1/adapters/field-support). MailerSend also gates custom
  `headers` behind its Professional and Enterprise plans.
</Callout>

## Verify from the CLI [#verify-from-the-cli]

```bash
MAILERSEND_API_KEY="mlsn..." npx email-sdk doctor --adapter mailersend
```

```bash
MAILERSEND_API_KEY="mlsn..." npx email-sdk send \
  --adapter mailersend \
  --from "Acme <hello@acme.com>" \
  --to user@example.com \
  --subject "MailerSend smoke test" \
  --text "It works" \
  --dry-run
```

Drop `--dry-run` for one real send — that is the only check that proves the token, domain verification, and plan limits are ready.
