Node-RED Email Nodes
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
-
Failed to connect: 535-5.7.8 Username and Password not accepted. Learn more at
cause Incorrect credentials, or modern email providers like Gmail/Outlook requiring application-specific passwords or OAuth2.0.fixFor Gmail, generate an App Password. For Outlook/Exchange, configure OAuth2.0. Double-check username and password entries in the node configuration. -
Error: self-signed certificate in certificate chain
cause The email server uses a self-signed or untrusted SSL/TLS certificate, and Nodemailer (used by the node) rejects it for security reasons.fixIf safe to do so in your environment, try to find an option within the Email node configuration to disable SSL/TLS certificate verification, or install the server's certificate into your system's trust store. -
Error: ETIMEDOUT or ECONNREFUSED
cause Network connectivity issues, incorrect server address, or firewall blocking the SMTP/IMAP/POP3 port.fixVerify the email server address and port in the node configuration. Ensure network connectivity from your Node-RED instance to the email server, and check firewall rules. -
(No Sender) appears in the sent email's 'From' field, or `msg.from` is not respected.
cause The configured mail server does not allow arbitrary `FROM` addresses or requires `msg.from` to match the authenticated user.fixSet `msg.from` to an email address directly associated with the account used for authentication, or leave it blank to let the server use its default sender.
Warnings
- breaking Version 4.x introduced a breaking change for the `email-mta` node. Users must re-enter any user/passwords for authenticating incoming mail due to a property clash.
- breaking Node.js version requirements have significantly increased. Version 3.x requires Node.js v18+, and the current 5.x series requires Node.js v20.0.0 or newer.
- gotcha For GMail users, traditional password authentication is often insufficient. You will likely need to generate an application password or enable 'less secure app access' (though the latter is discouraged by Google).
- gotcha For Exchange and Outlook 365, direct username/password authentication is often deprecated or requires specific configurations. OAuth2.0 is the recommended and often mandatory authentication method.
- gotcha The `msg.from` property, if set, might be ignored or result in '(No Sender)' if the email address is not a valid userid or an email address associated with the sending mail server's credentials.
- gotcha Sending emails with self-signed SSL/TLS certificates can cause Nodemailer (used internally by this package) to refuse sending the message.
Install
-
npm install node-red-node-email -
yarn add node-red-node-email -
pnpm add node-red-node-email
Imports
- Email Input Node
import { EmailInputNode } from 'node-red-node-email';Install 'node-red-node-email' via Node-RED's 'Manage Palette' or `npm i node-red-node-email` in your Node-RED user directory.
- Email Output Node
const EmailOutputNode = require('node-red-node-email').output;Install 'node-red-node-email' via Node-RED's 'Manage Palette' or `npm i node-red-node-email` in your Node-RED user directory.
- Email MTA Node
import { EmailMtaNode } from 'node-red-node-email/mta';Install 'node-red-node-email' via Node-RED's 'Manage Palette' or `npm i node-red-node-email` in your Node-RED user directory.
Quickstart
// 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;