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

expresser-mailer

v3.1.1

Published

Email sending plugin for Expresser.

Downloads

29

Readme

Expresser Mailer

Before you start make sure you have set the main SMTP server details on settings.mailer.smtp and settings.mailer.from with a default "from" email address. An optional secondary can be also set on settings.mailer.smtp2, and will be used only in case the main server fails.

The template handler expects a base template called "base.html", with a keyword "{contents}" where the email contents should go.

If settings.app.cloud is true, the Mailer module will automatically figure out the SMTP details for the following email services: Mailgun, Mandrill, SendGrid.

Sample code

The example below shows how to load the "login.html" template, parse and update the keywords {user} and {registrationDate} with igor and with the current date, and send a login confirmation email. The "from" address will be the default "from" address set on the settings.

var expresser = require("expresser");
var template = expresser.mailer.getTemplate("login");
var keywords = {username: "igor", registrationDate: new Date()}
var loginMessage = expresser.mailer.parseTemplate(template, keywords);

// getting the template manually to set the email body:
expresser.mailer.send({body: loginMessage, subject: "Login confirmation", to: "[email protected]"});

// alternate method to use templates directly via options:
expresser.mailer.send({keywords: keywords, template: "login", subject: "Login confirmation", to: "[email protected]"});

Please note that you can also use a different SMTP transport server if needed, by creating your own SMTP transport object using the "createSmtp" helper. It accepts the same options as the ones set under settings.mailer.smtp. Example below:

var customSmtp = expresser.mailer.createSmtp({
    host: "my.smtp.com",
    port: "587"
})

expresser.mailer.send({subject: "Login confirmation", to: "[email protected]", smtp: customSmtp});

The Mailer module is a wrapper around Nodemailer, so some of its features can be used directly. The default SMTP transport objects are exposed as "smtp" and "smtp2". More info at [http://www.nodemailer.com].

For detailed info on specific features, check the annotated source on /docs folder.