Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodemailer-sequelize-queue

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodemailer-sequelize-queue

Queue for mails with nodemailer and cron scheduler

  • 0.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19
increased by5.56%
Maintainers
1
Weekly downloads
 
Created
Source

Nodemailer sequelize queue

This package allows to queue email and process it later by schedule using Nodemailer for sending mails, Sequelize for save queue to database and Node cron for scheduling.

Getting Started

Install nodemailer-sequelize-queue using npm:

npm i nodemailer-sequelize-queue

or use yarn

yarn add nodemailer-sequelize-queue

Usage

  1. Create NodemailerSequelizeQueue instance
import NodemailerSequelizeQueue from 'nodemailer-sequelize-queue'

const dbCredentials = {
  // See https://www.npmjs.com/package/sequelize for more options
  config: {
    username: process.env.db_username || '',
    password: process.env.db_password || '',
    database: process.env.db_database || '',
    host: process.env.db_host || '',
    dialect: 'mysql' as any,
  },
  // Alternatively you can use existing sequelize instance
  // sequelize: SequelizeInstane
}
// See https://www.npmjs.com/package/nodemailer for more options
const smtpCreds = {
  host: process.env.smtp_host,
  port: process.env.smtp_port ? process.env.smtp_port : 465,
}

const queue = new NodemailerSequelizeQueue(
  dbCredentials,
  smtpCreds,
  {
  // See https://www.npmjs.com/package/nodemailer for more expression options
  expression: '*/1 * * * *',
  // If -1, will try infinite times
  maxAttempts: 2,
  }
)
  1. Run cron schedule for sending mail (Only one time in root of the system)
queue.initScheduler()
  1. Add mail to queue
queue.queueMail({
  email_from: 'test@gmail.com',
  email_to: 'test@gmail.com',
  subject: 'test subject',
  html: 'test message',
  attachments: [
    {
      // Not required (see Nodemailer filename prop)
      filename: 'file.jpg',
      // Local or remote url (see Nodemailer path prop)
      path: 'https://picsum.photos/id/237/200/300',
    },
    ]
})

License

The MIT License (MIT). Please see License File for more information.

Keywords

FAQs

Package last updated on 17 Sep 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc