# ms-mailer-client

> client for ms-mailer

Latest version **8.3.1** (published 2024-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install ms-mailer-client
pnpm add ms-mailer-client
yarn add ms-mailer-client
bun add ms-mailer-client
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.3.1 |
| Published | 2024-01-20 |
| First published | 2015-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vitaly Aminev |
| Maintainers | avvs |
| Keywords | microservice, amqp, nodemailer, mailer, smtp |

## Links

- npm: https://www.npmjs.com/package/ms-mailer-client
- Repository: https://github.com/makeomatic/ms-mailer-client
- Homepage: https://github.com/makeomatic/ms-mailer-client#readme
- Issues: https://github.com/makeomatic/ms-mailer-client/issues
- npm.io page: https://npm.io/package/ms-mailer-client

## Dependencies (1)

- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2

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

- 8.3.1 (latest) — 2024-01-20
- 8.3.0 — 2024-01-20
- 8.2.0 — 2023-01-31
- 8.1.0 — 2021-02-25
- 8.0.2 — 2020-03-12
- 8.0.1 — 2018-10-15
- 8.0.0 — 2018-10-15
- 7.0.0 — 2018-01-19
- 6.0.2 — 2017-06-03
- 6.0.1 — 2017-06-03
- 6.0.0 — 2017-05-02
- 5.0.1 — 2016-11-29
- 5.0.0 — 2016-11-26
- 4.0.0 — 2016-08-03
- 3.0.0 — 2016-07-06
- … 8 more at https://npm.io/package/ms-mailer-client/versions

## README

# Mailer microservice client

Encapsulates raw AMQP methods into a convenience wrapper.

## Installation

`npm i ms-mailer-client -S`

## Usage

```js
const Mailer = require('ms-mailer-client');

const mailer = new Mailer(amqpTransport, {
  prefix: 'mailer',
  routes: {
    adhoc: 'adhoc',
    predefined: 'predefined'
  }
});

// use predefined email
const promisePredefined = mailer.send('support@makeomatic.ru', {
  // email body with nodemailer
});

// use adhoc account
const promiseAdhoc = mailer.send({
  // nodemailer smtp data
  service: 'gmail',
  auth: {

  }
}, {
  // nodemailer email body
});
```

### `send` method

```js
const Mailer = require('ms-mailer-client');
const mailer = new Mailer(transport, { /* config */ });

const promise = mailer.send('support@makeomatic.ru', {
  // nodemailer email body
  from: 'support@makeomatic.ru',
  to: 'test@example.com',
  subject: 'subj',
  text: 'some text',
  html: '<p>html version of some text</p>',
});

```

### `sendTemplate` method

```js
const Mailer = require('ms-mailer-client');
const mailer = new Mailer(transport, { /* config */ });

// can be used with adhoc account setup aswell
const promise = mailer.sendTemplate(
  'support@makeomatic.ru', 
  'reset', // template name
  {
    nodemailer: {
      from: 'support@makeomatic.ru',
      to: 'test@example.com',
      subject: 'subj',
    },
    ctx: {
      // template rendering context
      link: 'activation_link',
      name: 'John Doe',
    },
  }
);
```

Resulted promise can be fulfilled with rejection when
the requested template name does not exist.

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