npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

email-smtp-cron-delivery

v0.1.1

Published

send emails via configurable appenders

Downloads

192

Readme

Appenders and cron settings allows flexible email delivery options

Included appenders:

  • instant - Prevents flood of duplicate emails. Send an email out once. Once reset the email can be sent again.
  • escallating - Send emails out according to an escallating cron defined schedule which can be started or stopped as needed.
  • threshold - Send emails out according to a threshold number - less than, greater than, or equal to that number.
  • bundle - In a cron defined time period bundle messages to email en-mass.

Installation

npm install email-smtp-cron-delivery

Examples

  estd = require('email-smtp-cron-delivery')

  var email = new estd({smtp_config : {
      host: "smtp host goes here",
      port: "smtp port goes here",
      auth: {
        user: "user name here",
        pass: "password goes here",
        type: "SMTP",
      },
      secure: ""
    },
    emailThrottle : {
      cronTime: "0,15,30,45 0-59 * * * *"   /* This is optional. Cron setting for how often you want emails to be sent. */
    }
  }).init()
  
  var email_instant = email.appender({type: 'instant'})
  email_instant.add({
    email_setup : {
      "from": "some email address",
      "to": "some email address",
      "subject": "try me out",
      "html": "<h2>This will appear in the email</h2>"
    }
  })
  email_instant.add({
    email_setup : {
      "from": "some email address",
      "to": "some email address",
      "subject": "try me out",
      "html": "<h2>This is another email</h2>"
    }
  })
  
  var email_threshold = email.appender({
    type: 'threshold',
    threshold_number: 1000,
    test_as: 'greater_than'
  })
  email_threshold.add({
    email_setup : {
      "from": "some email address",
      "to": "some email address",
      "subject": "try me out",
      "html": "<h2>This will appear in the email</h2>"
    }
  })
  
  var email_escallating = email.appender({
    type: 'escallating'                         
  })
  email_escallating.add({cron_config : {
      cronTime: "0 0-59 * * * *"
    }
  })
  email_escallating.add({
    email_setup : {
      "from": "some email address",
      "to": "some email address",
      "subject": "try me out",
      "html": "<h2>This is the first email that will appear</h2>"
    }
  })
  email_escallating.add({
    email_setup : {
      "from": "some email address",
      "to": "some email address",
      "subject": "try me out",
      "html": "<h2>This is the second email that will appear</h2>"
    }
  })
  
  var email_bundle = t.email.appender({
    type: 'bundle'                         
  })
  email_bundle.add({
    email_setup : {
      "from": "some email address",
      "to": "some email address",
      "subject": "try me out",
      "html": "<h2>This is the first email that will appear</h2>"
    }
  })
  email_bundle.add({
    email_setup : {
      "from": "some email address",
      "to": "some email address",
      "subject": "try me out",
      "html": "<h2>This is the second email that will appear</h2>"
    }
  })
  email_bundle.add({
    bundle : {
      "html": "<h4>Here is something we need to know</h4>"
    }
  })
  email_bundle.add({
    bundle : {
      "html": "<h4>Something else</h4>"
    }
  })
  email_bundle.add({
    bundle : {
      "html": "<h4>Cool</h4>"
    }
  })
    

The following examples are various attempts to email:

  email_bundle.attempt().on('success', function(){
    email_bundle.then('stop').then('reset').then('clear_messages').add({
      bundle : {
        "html": "<h1>This is a new message</h1>"
      }
    }).attempt().on('error', function(obj){
      console.log('error: ' + obj.message)
    })
  }).on('error', function(obj){
    console.log('error: ' + obj.message)
  })

  email_instant.attempt().on('success', function(){
    email_instant.then('stop').then('reset')
  }).on('error', function(){
    console.log('error: ' + obj.message)
  })
  
  email_escallating.attempt().on('success', function(){
    email_escallating.attempt().on('success', function(){
      email_escallating.then('stop').then('reset').attempt().on('success', function(){
        email_escallating.then('stop').then('reset')
      }).on('error', function(){
        console.log('error: ' + obj.message)
      })
    }).on('error', function(){
      console.log('error: ' + obj.message)
    })
  }).on('error', function(){
    console.log('error: ' + obj.message)
  })

  email_threshold.attempt({submit: 1001}).on('success', function(obj){
    console.log('threshold debug 10.00')
  }).on('error', function(){
    console.log('error: ' + obj.message)
  })
  
....