# cloudmailin

> Official Node.js for the CloudMailin Email API - https://www.cloudmailin.com

Latest version **0.3.1** (published 2026-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install cloudmailin
pnpm add cloudmailin
yarn add cloudmailin
bun add cloudmailin
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2026-03-04 |
| First published | 2021-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 30 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | CloudMailin |
| Maintainers | scsmith |
| Keywords | cloudmailin, email, mail, smtp, send, headers, nodemailer |

## Links

- npm: https://www.npmjs.com/package/cloudmailin
- Repository: https://github.com/cloudmailin/cloudmailin-js
- Homepage: https://www.cloudmailin.com
- Issues: https://github.com/cloudmailin/cloudmailin-js/issues
- npm.io page: https://npm.io/package/cloudmailin

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.13.6

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2026-03-04
- 0.3.0 — 2026-03-04
- 0.2.0 — 2025-09-16
- 0.1.0 — 2024-01-23
- 0.0.3 — 2021-03-09
- 0.0.2 — 2021-02-27

## README

<a href="https://www.cloudmailin.com">
  <img src="https://assets.cloudmailin.com/assets/favicon.png" alt="CloudMailin Logo" height="60" align="right" title="CloudMailin">
</a>

# CloudMailin Node.js Library

A Node.JS SDK for CloudMailin written in Typescript for receiving
incoming email via JSON HTTP POST.

Please see the [Documentation](https://docs.cloudmailin.com) for more details and examples.

## Usage

You can install the library using NPM.

```sh
npm install cloudmailin
```

### Receiving Email

We recommend you take a look at our
[Documentation](https://docs.cloudmailin.com/receiving_email/examples/node/)
for a more detailed example but here's a snippet:

```typescript
import express from "express";
import bodyParser from "body-parser";
import { IncomingMail } from "cloudmailin";

const app = express();
app.use(bodyParser.json());

app.post("/incoming_mails/", (req, res) => {
  const mail = <IncomingMail>req.body;

  res.status(201).json(mail);
}
```

### Sending Email

You can initialize the MessageClient in two ways:

#### Using explicit credentials

```typescript
import { MessageClient } from "cloudmailin"

const client = new MessageClient({
  username: "your-username",
  apiKey: "your-api-key"
});
const response = await client.sendMessage({
  to: 'test@example.net',
  from: 'test@example.com',
  plain: 'test message',
  html:  '<h1>Test Message</h1>',
  subject: "hello world"
});
```

#### Using SMTP URL (options or environment variable)

You can provide the SMTP URL either as an option or via environment variable:

**Option 1: Pass smtpUrl directly**
```typescript
import { MessageClient } from "cloudmailin"

const client = new MessageClient({
  smtpUrl: "smtp://username:apikey@smtp.cloudmta.net:587?starttls=true"
});
const response = await client.sendMessage({
  to: 'test@example.net',
  from: 'test@example.com',
  plain: 'test message',
  html:  '<h1>Test Message</h1>',
  subject: "hello world"
});
```

**Option 2: Use environment variable**
```bash
export CLOUDMAILIN_SMTP_URL="smtp://username:apikey@smtp.cloudmta.net:587?starttls=true"
```

```typescript
import { MessageClient } from "cloudmailin"

const client = new MessageClient(); // Will automatically use CLOUDMAILIN_SMTP_URL
const response = await client.sendMessage({
  to: 'test@example.net',
  from: 'test@example.com',
  plain: 'test message',
  html:  '<h1>Test Message</h1>',
  subject: "hello world"
});
```

**Note:** The SMTP URL format is `smtp://username:apikey@host:port?params`.
The host and port in the URL are not used for the API calls - the library
automatically uses the correct CloudMailin API endpoint at
`https://api.cloudmailin.com/api/v0.1/{username}/messages`.

## Development

Generating the OpenAPI reference:

```sh
npx openapi-typescript ./path_to/api.yaml --output ./src/models/cloudmailin-api.ts
```

---
_Source: https://npm.io/package/cloudmailin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
