# micromta

> Lightweight Mail Transfer Agent (SMTP server) for node.js. Inbound mail only.

Latest version **1.1.2** (published 2023-10-02) · BSD-3-Clause-Clear license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2023-10-02 |
| First published | 2020-03-23 |
| Weekly downloads | 0 |
| License | BSD-3-Clause-Clear |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 40.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Mat Sz |
| Maintainers | mat-sz |
| Keywords | email, e-mail, mail, mta, smtp, server, typescript |

## Links

- npm: https://www.npmjs.com/package/micromta
- Repository: https://github.com/mat-sz/microMTA
- Issues: https://github.com/mat-sz/microMTA/issues
- npm.io page: https://npm.io/package/micromta

## Dependencies (2)

- [base64-js](https://npm.io/package/base64-js.md) ^1.3.1
- [@types/node](https://npm.io/package/@types/node.md) ^14.0.27

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

- 1.1.2 (latest) — 2023-10-02
- 1.1.1 — 2021-09-18
- 1.1.0 — 2020-08-17
- 1.0.1 — 2020-04-13
- 1.0.0 — 2020-03-26
- 0.0.1 — 2020-03-23

## README

# NOTICE: This project will no longer be maintained, please use [`@typemail/smtp`](https://github.com/typemail/smtp) instead.

<h1 align="center">
  <img src="https://raw.githubusercontent.com/mat-sz/micromta/master/logo.png" alt="microMTA" width="500">
</h1>

<h2 align="center">
microMTA / µMTA
</h2>

<p align="center">
<img alt="workflow" src="https://img.shields.io/github/workflow/status/mat-sz/micromta/Node.js%20CI%20(yarn)">
<a href="https://npmjs.com/package/micromta">
<img alt="npm" src="https://img.shields.io/npm/v/micromta">
<img alt="npm" src="https://img.shields.io/npm/dw/micromta">
<img alt="NPM" src="https://img.shields.io/npm/l/micromta">
</a>
</p>

microMTA is a [Mail Transfer Agent (MTA)](https://en.wikipedia.org/wiki/Message_transfer_agent) library for node.js that focuses on receiving messages. The only feature of microMTA is message receiving. No sending or relaying will be possible since the library itself is not designed to handle that.

microMTA was created for [testing e-mail sending](https://github.com/mat-sz/catchmail-ws) in an application, by mocking a SMTP server. By default it runs on port 25 (which requires superuser privileges or an authbind/setcap setup).

The library is available in [npm](https://npmjs.org/package/micromta), use `yarn add micromta` or `npm install micromta` to install.

| Parser                                                 | Builder                                                  |
| ------------------------------------------------------ | -------------------------------------------------------- |
| [letterparser](https://github.com/mat-sz/letterparser) | [letterbuilder](https://github.com/mat-sz/letterbuilder) |

## Example

```js
const mta = new microMTA();
mta.on('message', message => console.log(message));

// Later:
mta.close();
```

`message` will be of the type _microMTAMessage_:

```ts
export interface microMTAMessage {
  recipients: string[];
  sender: string;
  message: string;
}
```

The `message` is a raw message that needs to be parsed. [letterparser](https://github.com/mat-sz/letterparser) can be used to parse and extract data from the raw messages.

## Options

The constructor for `microMTA` accepts an options object.

| Property       | Default value | Description                                                                                                              |
| -------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `ip`           | `0.0.0.0`     | IP address to bind to.                                                                                                   |
| `port`         | `25`          | Port to bind to. (Ports under 1024 usually require superuser privileges.)                                                |
| `hostname`     | `localhost`   | Hostname advertised by the SMTP server.                                                                                  |
| `size`         | `1000000`     | Maximum message size (in bytes).                                                                                         |
| `tls`          | `undefined`   | [createSecureContext options](https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options) for STARTTLS support. |
| `tlsPost`      | `465`         | Port for secure only communication, only enabled if `tls` is configured properly.                                        |
| `authenticate` | `undefined`   | Authentication function. See [Authentication](#Authentication) for more details.                                         |

## Events

### `message`

Emitted when a message is succesfully received.

### `error`

Emitted when an error occurs.

### `rejected`

Emitted when a message is rejected. For now, this only happens when the message exceeds the maximum size.

## Authentication

microMTA supports PLAIN and LOGIN methods for SMTP authentication. To enable authentication, a function of following type must be passed with the options object:

```ts
  authenticate?: (
    connection: microMTAConnection,
    username: string,
    password: string,
    authorizationIdentity?: string
  ) => boolean | Promise<boolean>;
```

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