Socket
Socket
Sign inDemoInstall

@notifications-system/transport-mailer

Package Overview
Dependencies
4
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @notifications-system/transport-mailer

Mail transport for Notifications System


Version published
Maintainers
2
Created

Readme

Source

Notifications System mailer transport

Description

Nodemailer transport for Notifications System

Install

npm i @notifications-system/transport-mailer

Usage

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

let service: NotificationService;

async function main() {
  // Instantiate Notification Service
  service = new NotificationService(
    await new MemoryStorage().initialize(),
    [
      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 `IOriginalData` format to transport specific `IMailData` format
      }, new MailDataProvider()),
      // ...,
      // new TRANSPORT_XXXX(),
    ],
  );
  new NotificationQueueManager(service).queueStart();


  // Sample usage
  const data: IOriginalData = { recipient: 'user@mail.test', payload: 'Test Notification' };
  service.send([TRANSPORT_SMTP/*, TRANSPORT_XXXX*/], data);
}

Keywords

FAQs

Last updated on 13 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc