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

# Sending Emails

> Send emails to your audience through campaigns

## Overview

Send emails to your audience using [campaigns](/campaigns/overview). Campaigns let you select a segment or list as recipients, configure sender settings, and track results.

<Frame caption="Real-time delivery logs with open, click, and bounce tracking">
  <img src="https://cdn.migma.ai/projects/67fdc02c3fceaac11f443bdd/images/sc-000746-2026-02-20_2x-8meu0v.png" alt="Email logs and tracking" />
</Frame>

<Info>
  Email sending in Migma is done through the **Campaigns** section, not from the Contacts page directly.
</Info>

***

## Quick Start

<Steps>
  <Step title="Create your email">
    Use Migma's AI tools to [create an email](/creating-emails/overview) in the chat editor.
  </Step>

  <Step title="Set up your audience">
    Add contacts, organize with [lists](/audience/overview), and create [segments](/audience/overview) from the Audience page.
  </Step>

  <Step title="Create a campaign">
    Go to **Campaigns** and [create a campaign](/campaigns/send-campaign). Select your email, choose recipients (segment or list), configure sender settings, and send or schedule.
  </Step>
</Steps>

***

## Prerequisites

<Warning>
  **Email service provider required** — configure an ESP before sending.
</Warning>

* Connected email provider (Migma, Amazon SES, Resend, SendGrid, or Mailgun)
* Verified sending domain
* At least one contact with `subscribed` status

<Card title="Setup Email Provider" icon="server" href="/integrations/email-service-providers">
  Connect and configure your email service provider
</Card>

***

## Unsubscribe & Compliance

Migma handles compliance automatically:

* Unsubscribe links are added to every marketing email
* Clicking unsubscribe updates the contact's status immediately
* Unsubscribed contacts cannot receive marketing emails
* [Preference center](/audience/preference-center) lets subscribers manage their topic preferences

***

## Send via API

Send emails programmatically via the [SDK](/sdk), [CLI](/cli), or [API](/api-reference/introduction).

The `from` address determines your **sending domain** — it must be a [verified domain](/sending-domains/overview). The optional `providerType` field selects which email service provider delivers the message. It defaults to `migma` (built-in sending).

For generated emails, use the `emailId` returned by generation status or shown in **Publish → Send via API**. `conversationId` identifies the whole chat thread; it works for single-email conversations, but multi-slot emails and series need `emailId` so the API knows which email to send.

```typescript theme={null}
await migma.sending.send({
  recipientType: 'email',
  recipientEmail: 'sarah@example.com',
  from: 'hello@yourcompany.migma.email',
  fromName: 'Your Company',
  subject: 'Welcome!',
  emailId: 'email_123'
});
```

<Tabs>
  <Tab title="Migma (default)">
    No `providerType` needed — Migma sends by default. Use a [verified sending domain](/sending-domains/overview) (managed or custom).

    ```typescript theme={null}
    await migma.sending.send({
      recipientType: 'email',
      recipientEmail: 'sarah@example.com',
      from: 'hello@yourcompany.migma.email',
      fromName: 'Your Company',
      subject: 'Welcome!',
      template: source,
      projectId: 'proj_123'
    });
    ```
  </Tab>

  <Tab title="Amazon SES">
    Requires [Amazon SES connected](/integrations/email-service-providers#amazon-ses-simple-email-service) in Settings → Integrations.

    ```typescript theme={null}
    await migma.sending.send({
      recipientType: 'email',
      recipientEmail: 'sarah@example.com',
      from: 'hello@yourdomain.com',
      fromName: 'Your Company',
      subject: 'Welcome!',
      template: source,
      projectId: 'proj_123',
      providerType: 'ses'
    });
    ```
  </Tab>

  <Tab title="Resend">
    Requires [Resend connected](/integrations/email-service-providers#resend) in Settings → Integrations.

    ```typescript theme={null}
    await migma.sending.send({
      recipientType: 'email',
      recipientEmail: 'sarah@example.com',
      from: 'hello@yourdomain.com',
      fromName: 'Your Company',
      subject: 'Welcome!',
      template: source,
      projectId: 'proj_123',
      providerType: 'resend'
    });
    ```
  </Tab>

  <Tab title="SendGrid">
    Requires [SendGrid connected](/integrations/email-service-providers#sendgrid) in Settings → Integrations.

    ```typescript theme={null}
    await migma.sending.send({
      recipientType: 'email',
      recipientEmail: 'sarah@example.com',
      from: 'hello@yourdomain.com',
      fromName: 'Your Company',
      subject: 'Welcome!',
      template: source,
      projectId: 'proj_123',
      providerType: 'sendgrid'
    });
    ```
  </Tab>

  <Tab title="Mailgun">
    Requires Mailgun connected in Settings → Integrations.

    ```typescript theme={null}
    await migma.sending.send({
      recipientType: 'email',
      recipientEmail: 'sarah@example.com',
      from: 'hello@yourdomain.com',
      fromName: 'Your Company',
      subject: 'Welcome!',
      template: source,
      projectId: 'proj_123',
      providerType: 'mailgun'
    });
    ```
  </Tab>
</Tabs>

<CardGroup cols={2}>
  <Card title="Sending Domains" icon="globe" href="/sending-domains/overview">
    Set up and verify a sending domain
  </Card>

  <Card title="Email Service Providers" icon="server" href="/integrations/email-service-providers">
    Connect an external ESP
  </Card>
</CardGroup>

***

## Transactional vs Marketing

Migma automatically infers the email type from how you send:

| Send type                                        | Default behavior | Example                              |
| ------------------------------------------------ | ---------------- | ------------------------------------ |
| **Single recipient** (`recipientType: 'email'`)  | Transactional    | Order confirmations, password resets |
| **Batch** (`recipientType: 'audience'`, `'tag'`) | Marketing        | Newsletters, promotions              |

**Transactional** emails bypass subscription status, skip topic filtering, and omit List-Unsubscribe headers. Bounced addresses are always excluded.

This means single sends just work — no extra flags needed:

```typescript theme={null}
// Automatically treated as transactional — no flag needed
await migma.sending.send({
  recipientType: 'email',
  recipientEmail: 'customer@example.com',
  from: 'noreply@yourcompany.migma.email',
  fromName: 'Your Company',
  subject: 'Your order has shipped',
  template: source,
  projectId: 'proj_123'
});
```

For edge cases, use the `transactional` flag to override the default:

```typescript theme={null}
// Batch transactional: "Your subscription renews tomorrow" to all active users
await migma.sending.send({
  recipientType: 'tag',
  recipientId: 'tag_active_subscribers',
  from: 'noreply@yourcompany.migma.email',
  fromName: 'Your Company',
  subject: 'Your subscription renews tomorrow',
  template: source,
  projectId: 'proj_123',
  transactional: true
});
```

<Warning>
  Only use `transactional: true` on batch sends for emails the recipient expects regardless of subscription status (renewal reminders, security alerts). Using it for promotional content violates CAN-SPAM and GDPR.
</Warning>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Send a Campaign" icon="rocket" href="/campaigns/send-campaign">
    Step-by-step campaign guide
  </Card>

  <Card title="Track Results" icon="chart-line" href="/campaigns/track-results">
    Monitor campaign performance
  </Card>

  <Card title="Manage Contacts" icon="users" href="/audience/manage-contacts">
    Organize your subscriber list
  </Card>

  <Card title="Setup ESP" icon="server" href="/integrations/email-service-providers">
    Connect email service provider
  </Card>
</CardGroup>
