# Zupost

## Node.js

> Category: Quickstart

---

## Pages


### Getting started

- [What is Zupost?](https://docs.zupost.com/getting-started/what-is-zupost)
- [Rate Limits](https://docs.zupost.com/getting-started/rate-limits)

### Quickstart

- [Node.js](https://docs.zupost.com/quickstart/node-js)

### Resources

- [Security](https://docs.zupost.com/resources/security)
- [Acceptable Use](https://docs.zupost.com/resources/acceptable-use)
- [Data Processing](https://docs.zupost.com/resources/data-processing)

---

# Node.js

There are many various ways of sending emails with Zupost. It can be a template, created in our no-code-editor. HTML, a react email or just markdown. No matter what you prefer, Zupost has it for you. And if you encounter issues with the documentation or the SDK, don't hesitate to open a Issue.

## Installation

Start by installing the official Zupost package with your favorite package manager.

```bash
pnpm install zupost
```

## Setting Up

After successfully installing Zupost to your project, you can start by creating a Zupost instance.

```typescript name="mail.ts"
const zupost = new Zupost('your-api-key');
```

## Sending Emails

You can send emails in various ways, see some usage examples:

### Send Html

```typescript name="mail.ts"
const { emailId } = await zupost.emails.send({
	from: 'sender@example.com',
	to: 'recipient@example.com',
	subject: 'Hello World',
	html: '<h1>Hello!</h1>',
});
```

### With React

The Zupost SDK is out of the box compatible with sending ++[react emails](https://react.email/)++.

```typescript name="mail.tsx"
const { emailId } = await zupost.emails.send({
	from: 'sender@example.com',
	to: 'recipient@example.com',
	subject: 'Welcome!',
	react: <WelcomeEmail name="John" />,
});
```

### With a Template

```typescript name="mail.ts"
const { emailId } = await zupost.emails.send({
	from: 'sender@example.com',
	to: 'recipient@example.com',
	subject: 'Welcome!',
	templateId: 'welcome-template',
	variables: { name: 'John' },
});

```

### With Attachments

You can attach files to your emails by providing them as base64-encoded strings.

```typescript name="mail.ts"
import { fs } from 'fs';

const { emailId } = await zupost.emails.send({
	from: 'sender@example.com',
	to: 'recipient@example.com',
	subject: 'Invoice',
	html: 'Please find the invoice attached.',
	attachments: [
		{
			filename: 'invoice.pdf',
			content: fs.readFileSync('/path/to/invoice.pdf').toString('base64'),
		},
	],
});
```

