Skip to content

nodemailer wrapper with retries and other goodies

License

Notifications You must be signed in to change notification settings

maielo/nm-sender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nm-sender

Wrapper around nodemailer for sending emails via smtp with retries and on-error email notification

  • pool is automatically set to true (maxConnections: 5)
  • mailOptions - docs

install

npm i nm-sender
// ES6 modules
import NmSender from 'nm-sender';
// commonJS
const NmSender = require('nm-sender').default;

/**
 * ALL OPTIONS
  retryTime?: number;
  maxRetries?: number;
  host: string;
  port: number;
  tls?: boolean; // default true
  user: string;
  password: string;
  defaultFromAddress: string;
  errorAddress?: string;
 *
 */
const e = new NmSender({
  host: 'smtp.xxxx.com',
  port: 465,
  user: '[email protected]',
  password: 'xxxx',
  defaultFromAddress: '[email protected]',
});

// ...
// DOCS: https://nodemailer.com/message/
try {
  await e.sendMail({
    to: '[email protected]',
    subject: 'My subject',
    from: '[email protected]',
    text: 'Hello my email world',
  });
} catch (err) {
  console.error(err);
}

About

nodemailer wrapper with retries and other goodies

Resources

License

Stars

Watchers

Forks

Packages

No packages published