@node-notifications/transport-mailer
v3.1.0
Published
Mail transport for Notification System
Downloads
278
Readme
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: '[email protected]', payload: 'Test Notification', transports: ['smtp'] }).then();
}