3.1.0 • Published 11 months ago

@node-notifications/transport-mailer v3.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

Notification System mailer transport

Description

Nodemailer transport for Notification System

Install

yarn add @node-notifications/transport-mailer

Usage

import { MemoryStorage, NotificationQueueManager, NotificationService } from '@node-notifications/core';
import { MailDataProvider, SmtpTransport } from '@node-notifications/transport-mailer';

let service: NotificationService;
let queueManager: NotificationQueueManager;

async function main() {
  // Instantiate Notification Service
  service = new NotificationService(
    await new MemoryStorage().initialize(),
    {
      smtp: new SmtpTransport({
        options: {
          host: process.env.MAIL_HOST,
          port: Number(process.env.MAIL_PORT) || undefined,
          auth: {
            user: process.env.MAIL_USER,
            pass: process.env.MAIL_PASS,
          },
        },
        defaults: {
          from: process.env.MAIL_FROM,
        },
        // MailDataProvider - IDataProvider implementation to transform data from `INotification` format to `IMailData` format
      }, new MailDataProvider()),
    },
  );

  // Instantiate Notification Queue Manager
  queueManager = new NotificationQueueManager(service).start();

  // ...

  // Sample usage (data: INotification)
  service.send({ recipient: 'user@mail.test', payload: 'Test Notification', transports: ['smtp'] }).then();
}
3.1.0

11 months ago

3.0.1

11 months ago

3.0.0

11 months ago

2.1.5

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago