This page is the JavaScript-focused companion to the broader [sending emails guide](/guides/sending-emails/). Use it when you already know you want the MailSlurp SDK or API send path in app code and test suites.

If you are still choosing between browser `mailto:`, Node.js SMTP, and backend email API patterns, start with [Send email with JavaScript](/blog/javascript-send-email/).

## Core API call

The primary call shape is:

```typescript
sendEmail(inboxId: string, sendEmailOptions: SendEmailOptions): Promise<Response>
```

- `inboxId`: the MailSlurp inbox that sends the message.
- `sendEmailOptions`: recipients, content, headers, and delivery options.

## Minimum payload

`to` is the key field most workflows start with:

```typescript
await mailslurp.sendEmail(inboxId, {
  to: ["user@mycompany.com"],
  subject: "Welcome",
  body: "Your account is ready",
});
```

## Common SendEmailOptions fields

```typescript
interface SendEmailOptions {
  to?: string[];
  cc?: string[];
  bcc?: string[];
  subject?: string;
  body?: string;
  html?: boolean;
  attachments?: string[];
  templateVariables?: Record<string, unknown>;
  replyTo?: string;
  from?: string;
  charset?: string;
}
```

Use named senders where needed:

- Plain: `qa@example.com`
- Named: `"QA Team" <qa@example.com>`

## HTML and template variables

Set `html: true` when sending markup-based email:

```typescript
await mailslurp.sendEmail(inboxId, {
  to: ["user@test.com"],
  subject: "Verify your account",
  body: "<p>Use code <strong>483921</strong></p>",
  html: true,
});
```

For reusable transactional messages, use template variables:

```typescript
await mailslurp.sendEmail(inboxId, {
  to: ["user@test.com"],
  body: "Hello {{name}}",
  templateVariables: { name: "Ari" },
});
```

## Attachments in Node.js

Workflow:

1. Read file bytes.
2. Convert to base64.
3. Upload attachment.
4. Send using returned attachment IDs.

```typescript
import { readFileSync } from "fs";

const bytes = readFileSync("./invoice.pdf");
const base64Contents = Buffer.from(bytes).toString("base64");
```

See [base64 uploads](/guides/base64-file-uploads/) for language-specific patterns.

## Production-safe sending checklist

- Validate recipient quality before high-volume sends.
- Use queue-backed send flows for retry resilience.
- Add delivery/bounce webhooks for visibility.
- Keep sender identity (SPF/DKIM/DMARC) aligned with your domain policy.

Related:

- [Send emails guide](/guides/sending-emails/)
- [Email webhooks](/guides/email-webhooks/)
- [Deliverability testing](/testing/email-deliverability-test/)
- [Email Sandbox](/product/email-sandbox/)

## Next step

If this is part of test automation, move to [receive emails in code](/guides/developers/receiving-email/) and add deterministic receive-side assertions.
