Node-RED Email Nodes

5.2.3 · active · verified Sun Apr 19

node-red-node-email provides a set of nodes for the Node-RED visual programming environment, enabling users to easily send and receive emails within their flows. The current stable version is 5.2.3. The package offers an 'Email (input)' node to fetch messages from IMAP or POP3 servers, and an 'Email (output)' node to send emails via SMTP. It supports modern authentication methods such as OAuth2.0 for Exchange/Outlook 365 and application-specific passwords for Gmail, which are crucial for two-factor authentication setups. Releases are tied to Node.js version requirements, with recent versions requiring Node.js v20 or newer, and major updates often introducing breaking changes related to authentication mechanisms. Its primary differentiator is seamless integration into Node-RED, abstracting complex email protocols into configurable visual components, allowing for robust email automation directly within flows.

Common errors

Warnings

Install

Imports

Quickstart

This code prepares a message object (`msg`) within a Node-RED Function node, which the 'Email (output)' node then uses to send an email with a subject, body, sender, recipient, and optional attachments.

// This JavaScript snippet demonstrates preparing an email message object
// within a Node-RED Function node, which can then be wired to an
// 'Email (output)' node for sending.

// Set the email recipient
msg.to = "recipient@example.com";

// Set the email subject
msg.topic = "Automated Report from Node-RED";

// Set the email sender (may require valid credentials for the SMTP server)
msg.from = "no-reply@yourdomain.com";

// Set the email body (plain text or HTML)
msg.payload = "Hello,\n\nThis is an automated email report generated by Node-RED.\n\nRegards,\nYour System";

// Optionally, add an HTML version of the body
// msg.html = "<h1>Automated Report</h1><p>Hello,</p><p>This is an <b>automated email report</b> generated by Node-RED.</p><p>Regards,<br/>Your System</p>";

// Optionally, add attachments (using Nodemailer format)
msg.attachments = [
    {
        filename: 'data.txt',
        content: 'Content of the attached file, for example: Key=Value\nStatus=OK',
        contentType: 'text/plain'
    }
];

// Return the modified message object for the next node in the flow
return msg;

view raw JSON →