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

node-red-node-email

v3.0.2

Published

Node-RED nodes to send and receive simple emails.

Downloads

20,498

Readme

node-red-node-email

Node-RED nodes to send and receive simple emails.

Pre-requisite

You will need valid email credentials for your email server. For GMail this may mean getting an application password if you have two-factor authentication enabled.

For Exchange and Outlook 365 you must use OAuth2.0.

**Notes **: Version 3.x of this node requires Node.js v18 or newer. Version 2.x of this node requires Node.js v16 or newer. Version 1.91 of this node required Node.js v14 or newer. Previous versions of this node required Node.js v8 or newer.

Install

You can install by using the Menu - Manage Palette option, or running the following command in your Node-RED user directory - typically ~/.node-red

    cd ~/.node-red
    npm i node-red-node-email

GMail users

If you are accessing GMail you may need to either enable an application password, or enable less secure access via your Google account settings.

Office 365 users

If you are accessing Exchange you will need to register an application through their platform and use OAuth2.0. Details on how to do this can be found here.

Usage

Nodes to send and receive simple emails.

Input node

Fetches emails from an IMAP or POP3 server and forwards them onwards as messages if not already seen.

The subject is loaded into msg.topic and msg.payload is the plain text body. If there is text/html then that is returned in msg.html. msg.from and msg.date are also set if you need them.

Additionally msg.header contains the complete header object including to, cc and other potentially useful properties.

Modern authentication through OAuth2.0 is supported, but must be triggered by an incoming access token and can only be automatically triggered upstream.

Output node

Sends the msg.payload as an email, with a subject of msg.topic.

The default message recipient can be configured in the node, if it is left blank it should be set using the msg.to property of the incoming message. You can also specify any or all of: msg.cc, msg.bcc, msg.replyTo, msg.inReplyTo, msg.references, msg.headers, or msg.priority properties.

The email from can be set using msg.from but not all mail services allow this unless msg.from is also a valid userid or email address associated with the password. Note: if userid or msg.from does not contain a valid email address (userxx@some_domain.com), you may see (No Sender) in the email.

The payload can be html format. You can also specify msg.plaintext if the main payload is html.

If the payload is a binary buffer, then it will be converted to an attachment.

The filename should be set using msg.filename. Optionally msg.description can be added for the body text.

Alternatively you may provide msg.attachments which should contain an array of one or more attachments in nodemailer format.

If required by your recipient you may also pass in a msg.envelope object, typically containing extra from and to properties.

If you have own signed certificates, Nodemailer can complain about that and refuse sending the message. In this case you can try switching off TLS.

Use secure connection - If enabled the connection will use TLS when connecting to server. If disabled then TLS is used if server supports the STARTTLS extension. In most cases set this to enabled if you are connecting to port 465. For port 587 or 25 keep it disabled.

This node uses the nodemailer npm module.

Testing

You can pass the credentials object to the node-red-node-test-helper by doing the following:

const emailNode = require("./61-email");

const testFlows = [{
    id: "n1", type: "e-mail", name: "Email",
    from: "[email protected]", subject: "TestSubject", server: "testServer",
    port: "1111", secure: "X", tls: true, authtype: "BASIC",
}];

const testCredentials = {
    n1: {
        userid: "ExampleUser",
        password: "ExamplePassword",
        global: false
    }
};

it('should be loaded', function (done) {
    helper.load(emailNode, testFlows, testCredentials, function () {
        const n1 = helper.getNode("n1");
        try {
            n1.should.have.property('name', 'Email');
            n1.should.have.property('from', '[email protected]');
            n1.should.have.property('subject', 'TestSubject');
            n1.should.have.property('outserver', 'testServer'); // Gathered via server
            n1.should.have.property('outport', '1111'); // Gathered via port
            n1.should.have.property('secure', 'X');
            n1.should.have.property('tls', true);
            n1.should.have.property('authtype', 'BASIC');
            n1.should.have.property('credentials');
            n1.should.have.property('credentials', {
                userid: "ExampleUser",
                password: "ExamplePassword",
                global: false
            });
            done();
        } catch (err) {
            done(err);
        }
    });
});