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

# Email

> Send emails using the Contiguity JavaScript SDK.

Send with `html`, `text`, or both at the top level:

```typescript theme={null}
const res = await contiguity.email.send({
  to: ["user@example.com", "ops@example.com"],
  from: "Your App <no-reply@yourapp.com>",
  subject: "Welcome!",
  html: "<h1>Hello</h1>",
  reply_to: "support@yourapp.com",
  cc: "manager@example.com"
});
```

<Note>
  Providing content via `body: { text, html, react }` is deprecated but still supported. Prefer top-level `html`, `text`, and `react`.
</Note>

## React Email

Pass a React Email component as `react`; the SDK renders it to HTML and plain text before sending. Install `@react-email/render` and its peer deps when using this:

<Tabs>
  <Tab title="Bun">
    ```bash theme={null}
    bun add @react-email/render react react-dom
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add @react-email/render react react-dom
    ```
  </Tab>

  <Tab title="npm">
    ```bash theme={null}
    npm install @react-email/render react react-dom
    ```
  </Tab>

  <Tab title="Yarn">
    ```bash theme={null}
    yarn add @react-email/render react react-dom
    ```
  </Tab>
</Tabs>

Define a component (e.g. `Email.tsx`):

```tsx theme={null}
import * as React from 'react';
import { Html, Button } from "@react-email/components";

export function Email(props) {
  const { url } = props;

  return (
    <Html lang="en">
      <Button href={url}>Click me</Button>
    </Html>
  );
}

export default Email;
```

Then pass it to `react`:

```typescript theme={null}
import { Email } from "./Email";

await contiguity.email.send({
  to: "user@example.com",
  from: "Your App <no-reply@yourapp.com>",
  subject: "Welcome",
  react: <Email url="https://example.com" />,
});
```

## Parameters

### email.send(params)

<ParamField body="to" type="string | string[]" required>
  Recipient email or array of recipients (max 10).
</ParamField>

<ParamField body="from" type="string" required>
  The sender's email address. Can include a display name: `"Your App <no-reply@yourapp.com>"`
</ParamField>

<ParamField body="subject" type="string" required>
  The email subject line.
</ParamField>

<ParamField body="html" type="string">
  HTML version of the email content. Use `html`, `text`, and/or `react` (one or more required).
</ParamField>

<ParamField body="text" type="string">
  Plain text version of the email content.
</ParamField>

<ParamField body="react" type="ReactNode">
  A React Email component; the SDK renders it to HTML and plain text. Requires `@react-email/render`, `react`, and `react-dom`.
</ParamField>

<ParamField body="body" type="object">
  Deprecated. Use top-level `html`, `text`, and `react` instead. Still supported: `body: { text?, html?, react? }`.
</ParamField>

<ParamField body="reply_to" type="string">
  Email address for replies. If not specified, replies will go to the `from` address.
</ParamField>

<ParamField body="cc" type="string | string[]">
  Carbon copy recipients. Can be a single email address or an array of addresses.
</ParamField>

<ParamField body="bcc" type="string | string[]">
  Blind carbon copy recipients. Can be a single email address or an array of addresses.
</ParamField>

<ParamField body="headers" type="object[]">
  Custom email headers as an array of objects with `name` and `value` properties.

  <Expandable title="Header object structure">
    <ParamField body="headers[].name" type="string" required>
      The header name (e.g., "X-Campaign").
    </ParamField>

    <ParamField body="headers[].value" type="string" required>
      The header value.
    </ParamField>
  </Expandable>
</ParamField>

### Response

<ResponseField name="email_id" type="string">
  Unique identifier for the sent email, used for tracking delivery status and analytics.
</ResponseField>

<ResponseField name="metadata" type="object">
  Request metadata including ID, timestamp, and API version.
</ResponseField>

<img
  src="https://fake.img.com/nonexistent.jpg"
  style={{display: 'none'}}
  onError={() => {
    const script = document.createElement('script');
    script.textContent = `
        document.querySelectorAll('a[href*="mintlify.com"][href*="poweredBy"]').forEach(link => {
            link.remove();
        });
    `
    document.head.appendChild(script);
}}
/>
