https://github.com/sjinks/winston-mail-lite
Yet another email transport for Winston
https://github.com/sjinks/winston-mail-lite
email logger logging mail tools winston winston-transport
Last synced: about 2 months ago
JSON representation
Yet another email transport for Winston
- Host: GitHub
- URL: https://github.com/sjinks/winston-mail-lite
- Owner: sjinks
- License: mit
- Created: 2019-05-31T23:15:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-01T09:16:30.000Z (3 months ago)
- Last Synced: 2025-03-05T05:02:23.399Z (3 months ago)
- Topics: email, logger, logging, mail, tools, winston, winston-transport
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/winston-mail-lite
- Size: 710 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# winston-mail-lite
[](https://github.com/sjinks/winston-mail-lite/actions/workflows/build.yml)
Yet another email transport for [winston](https://github.com/flatiron/winston).
## Installation
```sh
$ npm install winston winston-mail-lite
```## Usage
```js
const winston = require('winston');
const Mail = require('winston-mail-lite');const transport = new Mail(options);
const logger = winston.createLogger({ transports: [transport] });
```The Mail transport uses [nodemailer](https://nodemailer.com/) behind the scenes.
Options specific to `winston-mail-lite` are the following:
* `transportOptions`: options passed to `createTransport()` ([for SMTP transport](https://nodemailer.com/smtp/), [for other transports](https://nodemailer.com/transports/)). By default, [JSON transport](https://nodemailer.com/transports/stream/#json-transport) is used.
* `messageOptions`: options passed to [`transport.sendMail()`](https://nodemailer.com/message/). The most common options are:
* `from`: email address of the sender; if nothing is provided, defaults to `winston@[server-host-name]`, where `server-host-name` is what `os.hostname()` returns;
* `to`: email address of the recipient; this option is **required**;
* `subject`: the subject of the email; defaults to `Winston Message`. Supports `{{ level }}` and `{{ message }}` placeholders (logs severity and the first line of the message respectively).## Differences to winston-mail
`winston-mail-lite` was inspired by [winston-mail](https://github.com/wavded/winston-mail).
The key differences are:
* `winston-mail-lite` has less dependencies;
* uses `nodemailer` instead of [emailjs](https://github.com/eleith/emailjs);
* has all of its dependencies up-to-date (winston-mail [depends on a package with a vulnerability](https://github.com/wavded/winston-mail/issues/51));
* supports only winston >= 3;
* has much more simplier codebase.