# fake-smtp-server

> Fake SMTP Server for email testing

Latest version **0.8.0** (published 2018-12-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install fake-smtp-server
pnpm add fake-smtp-server
yarn add fake-smtp-server
bun add fake-smtp-server
```

Provides the command `fake-smtp-server`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2018-12-19 |
| First published | 2017-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.5.0 |
| Dependencies | 7 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 204 |
| Author | ReachFive |
| Maintainers | jcdelmas |
| Keywords | smtp, development, test, fake, dummy, mock, email, e-mail, automated, integration, ci |

## Links

- npm: https://www.npmjs.com/package/fake-smtp-server
- Repository: https://github.com/ReachFive/fake-smtp-server
- Issues: https://github.com/ReachFive/fake-smtp-server/issues
- npm.io page: https://npm.io/package/fake-smtp-server

## Dependencies (7)

- [cli](https://npm.io/package/cli.md) ^1.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [moment](https://npm.io/package/moment.md) ^2.18.1
- [express](https://npm.io/package/express.md) ^4.15.4
- [mailparser](https://npm.io/package/mailparser.md) ^2.0.5
- [smtp-server](https://npm.io/package/smtp-server.md) ^3.1.0
- [express-basic-auth](https://npm.io/package/express-basic-auth.md) ^1.1.3

## 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.8.0 (latest) — 2018-12-19
- 0.7.7 — 2018-06-05
- 0.7.6 — 2018-02-23
- 0.7.5 — 2018-02-17
- 0.7.4 — 2018-02-17
- 0.7.3 — 2018-02-05
- 0.7.2 — 2018-01-31
- 0.7.1 — 2018-01-10
- 0.7.0 — 2017-12-14
- 0.6.3 — 2017-12-04
- 0.6.2 — 2017-10-18
- 0.6.1 — 2017-10-18
- 0.6.0 — 2017-10-18
- 0.5.0 — 2017-10-18
- 0.4.0 — 2017-10-18
- … 3 more at https://npm.io/package/fake-smtp-server/versions

## README

# Fake SMTP Server

Fake SMTP Server is an email testing tool for QA & development teams. 
It allows manual testing in a web interface, and automated testing via an API.

## API

#### Listing all received emails

Received mails are listed on `http://localhost:1080/api/emails`, and looks like this:

```json
[
  {
    "attachments": [],
    "text": "Hi Bob!",
    "textAsHtml": "<p>Hi Bob!</p>",
    "subject": "Hi",
    "date": "2017-09-18T16:12:16.000Z",
    "to": {
      "value": [
        {
          "address": "bob@example.com",
          "name": "Bob"
        }
      ],
      "html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">Bob</span> &lt;<a href=\"mailto:bob@example.com\" class=\"mp_address_email\">bob@example.com</a>&gt;</span>",
      "text": "Bob <bob@example.com>"
    },
    "from": {
      "value": [
        {
          "address": "joe@example.com",
          "name": "Joe"
        }
      ],
      "html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">Joe</span> &lt;<a href=\"mailto:joe@example.com\" class=\"mp_address_email\">joe@example.com</a>&gt;</span>",
      "text": "Joe <joe@example.com>"
    },
    "messageId": "<1433879119.43.1505751136615@[10.143.108.87]>",
    "html": false
  }
]
```

You can filter emails with the following parameters:

 * `from`: filter sender
 * `to`: filter recipient
 * `since`: filter email date
 * `until`: filter email date
 
Example:

```
    GET http://localhost:1080/api/emails?from=joe@example.com&to=bob@example.com&since=2017-09-18T12:00:00Z&until=2017-09-19T00:00:00Z
```

##### Viewing headers in responses

By default, fake-smtp-server will not capture custom headers in emails. To enable headers, start the server with the `--headers` flag. If enabled, headers will be serialized as an object type. 

For reference for what headers look like, consult [Nodemailer's documentation](https://nodemailer.com/extras/mailparser/#headers-map), but keep in mind that the HTTP endpoint returns plain JSON objects rather than `Map`s.

#### Removing all received email

To remove all emails without restarting the server:
```
    DELETE http://localhost:1080/api/emails
``` 


## Web interface

Go to `http://localhost:1080`

## Install

```bash
  npm install -g fake-smtp-server
```

## Usage

```
Usage:
  fake-smtp-server [OPTIONS] [ARGS]

Options:
  -s, --smtp-port [NUMBER] SMTP port to listen on (Default is 1025)
      --smtp-ip [IP]       IP Address to bind SMTP service to (Default is 0.0.0.0)
  -h, --http-port [NUMBER] HTTP port to listen on (Default is 1080)
      --http-ip [IP]       IP Address to bind HTTP service to (Default is 0.0.0.0)
  -w, --whitelist STRING   Only accept e-mails from these adresses. Accepts
                           multiple e-mails comma-separated
  -m, --max [NUMBER]       Max number of e-mails to keep (Default is 100)
  -a, --auth STRING        Enable Authentication
      --headers            Enable headers in responses
  -k, --no-color           Omit color from output
      --debug              Show debug information
```

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