# Zupost

## SMTP

> 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)
- [SMTP](https://docs.zupost.com/quickstart/smtp)

### 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)

---

# Send emails with SMTP

There are many various ways of sending emails with Zupost. You can use the official SDK, send emails through the API, or connect an existing application through SMTP.

SMTP is useful when your application, framework, CMS, server, or tool already supports sending emails through a custom SMTP server.

## Configuration

Use the following settings in your application:


| Setting       | Value                     |
| ------------- | ------------------------- |
| SMTP host     | `relay.zupost.com`        |
| SMTP port     | `587` or `25`             |
| SMTP username | Your sender email address |
| SMTP password | A Zupost API key          |
| SMTP sender   | Your sender email address |


We recommend using port `587` whenever possible. Use port `25` only if your setup requires it.

## Authentication

Zupost uses SMTP authentication.

The SMTP username is the email address you want to send from. The SMTP password is an API key from your Zupost account.

```txt
Username: sender@example.com
Password: zupost_yourApiKey
```

## Sender Address

The sender address must be the same email address as the SMTP username.

```txt
Username: sender@example.com
Sender: sender@example.com
```

This allows Zupost to verify that the email is sent through an authorized sender.

## Environment Variables

Many applications use environment variables for SMTP configuration.

```env
SMTP_HOST=relay.zupost.com
SMTP_PORT=587
SMTP_USERNAME=sender@example.com
SMTP_PASSWORD=zp_your_api_key
SMTP_FROM=sender@example.com
```

## Example with Nodemailer

You can use Zupost with Nodemailer by configuring Zupost as the SMTP transport.

```ts
import nodemailer from 'nodemailer';

const transporter = nodemailer.createTransport({
	host: 'relay.zupost.com',
	port: 587,
	auth: {
		user: 'sender@example.com',
		pass: 'zp_your_api_key',
	},
});

const info = await transporter.sendMail({
	from: 'sender@example.com',
	to: 'recipient@example.com',
	subject: 'Hello World',
	html: '<h1>Hello!</h1>',
});

console.log(info.messageId);
```

## Troubleshooting

### Authentication failed

Make sure that your SMTP username is your sender email address and that your SMTP password is a valid Zupost API key.

### Sender is not accepted

Make sure that the sender address matches the SMTP username and that the sender address is configured in your Zupost account.

### Connection failed

Make sure that your application uses `relay.zupost.com` as the SMTP host and either `587` or `25` as the SMTP port.

Some hosting providers block outgoing SMTP connections on port `25`. In that case, use port `587`.