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

# Email SDK Reference

> Send custom transactional emails with the InsForge SDK

<CodeGroup>
  ```bash npm theme={null}
  npm install @insforge/sdk@latest
  ```

  ```bash yarn theme={null}
  yarn add @insforge/sdk@latest
  ```

  ```bash pnpm theme={null}
  pnpm add @insforge/sdk@latest
  ```
</CodeGroup>

```javascript theme={null}
import { createClient } from '@insforge/sdk';

const insforge = createClient({
  baseUrl: 'https://your-app.insforge.app',
  anonKey: 'your-anon-key'  // Optional: for public/unauthenticated requests
});
```

Find the anon key with `npx @insforge/cli secrets get ANON_KEY`, or in the dashboard: click **Install** and open **API Keys**.

## emails.send()

Send custom HTML emails to one or more recipients.

### Parameters

* `to` (string | string\[], required) - Recipient email(s), max 50 recipients
* `subject` (string, required) - Email subject line, max 500 characters
* `html` (string, required) - HTML content of the email
* `cc` (string | string\[], optional) - CC recipient(s), max 50 recipients
* `bcc` (string | string\[], optional) - BCC recipient(s), max 50 recipients
* `from` (string, optional) - Display name shown next to the sender address, max 100 characters (ignored when Custom SMTP is enabled)
* `replyTo` (string, optional) - Reply-to email address, must be a valid email address

<Note>
  By default, emails are sent from `noreply@<your-project>.send.insforge.dev`, a per-project subdomain that InsForge Cloud provisions and verifies for you, so no domain setup is required. The `from` field only sets the display name shown next to that address; on the default provider you cannot change the address or domain. To send from your own domain, configure [Custom SMTP](/core-concepts/messaging/custom-smtp). When Custom SMTP is enabled the `from` field is ignored entirely, and the sender name and email are taken from your SMTP configuration to prevent spoofing through your server.
</Note>

### Returns

```typescript theme={null}
{
  data: {} | null,  // Empty object on success
  error: Error | null
}
```

### Example

```javascript theme={null}
const { data, error } = await insforge.emails.send({
  to: ['user1@example.com', 'user2@example.com'],
  cc: 'manager@example.com',
  from: 'Acme Support Team',
  subject: 'Team Update',
  html: '<h1>Weekly Update</h1><p>Here are this week\'s highlights...</p>',
  replyTo: 'support@example.com'
});

if (error) {
  console.error('Failed to send email:', error.message);
  return;
}

console.log('Email sent successfully');
```
