nm-sender
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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: 'xxx@xxx.com',
  password: 'xxxx',
  defaultFromAddress: 'x@xxx.com',
});

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

Package Sidebar

Install

npm i nm-sender

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

34.2 kB

Total Files

15

Last publish

Collaborators

  • maielo