node-red-supemail-node 1.0.5

A Node-RED node for sending the latest file as an email attachment

npm install node-red-supemail-node

Node-RED Latest File Email Node

A Node-RED node that monitors a directory and sends the latest file as an email attachment.

Features

  • Monitors a specified directory for files
  • Sends the latest file as an email attachment
  • Configurable email server settings
  • Configurable sender and multiple recipients
  • Configurable email subject and body
  • Detailed error handling and logging
  • Secure password storage

Installation

Via Node-RED Palette Manager

  1. Open Node-RED
  2. Click Menu → Manage Palette
  3. Switch to "Install" tab
  4. Search for "node-red-email-node"
  5. Click Install

Manual Installation

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

Configuration

Email Server Settings

  1. Double click the node to open configuration
  2. Click the pencil icon next to "Email Config"
  3. Configure the following:
    • Name: A name for this configuration
    • Host: SMTP server hostname (e.g., smtp.gmail.com)
    • Port: SMTP server port (default: 587)
    • Secure: Use SSL/TLS (check for port 465)
    • User: SMTP username
    • Password: SMTP password
    • From: Sender email address
    • To: Recipient email addresses (multiple addresses can be separated by commas)
    • Subject: Email subject
    • Text: Email body text
    • Watch Directory: Directory to monitor for files

Node Settings

  • Name: Optional name for the node

Usage

  1. Deploy the node
  2. The node will trigger when it receives any input message
  3. It will find the latest file in the configured directory
  4. The file will be sent as an attachment to all configured email addresses

Input

Any message will trigger the node to send the latest file.

Output

The node outputs a message with the following properties:

{
    "payload": {
        "success": true,
        "messageId": "message-id",
        "file": "filename.ext",
        "recipients": ["[email protected]", "[email protected]"]
    }
}

Example Flow

[
    {
        "id": "trigger-node",
        "type": "inject",
        "name": "Trigger",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "wires": [
            [
                "email-node"
            ]
        ]
    },
    {
        "id": "email-node",
        "type": "email-node",
        "name": "Send Latest File",
        "emailConfig": "email-config-node",
        "wires": [
            [
                "debug-node"
            ]
        ]
    }
]

Development

Prerequisites

  • Node.js 14 or later
  • npm 6 or later

Setup

# Clone the repository
git clone https://github.com/yourusername/node-red-email-node.git

# Install dependencies
cd node-red-email-node
npm install

# Run tests
npm test

Testing

The node includes comprehensive tests:

  • File system operations
  • Email transport configuration
  • Email sending functionality
  • Error handling

Run tests with:

npm test

Troubleshooting

Common Issues

  1. No files found

    • Check if the watch directory exists
    • Verify directory permissions
  2. Email not sending

    • Verify SMTP server settings
    • Check credentials
    • Ensure network connectivity
  3. Authentication failed

    • Double-check username and password
    • For Gmail, you may need an App Password
  4. Multiple recipients not working

    • Ensure email addresses are separated by commas
    • Check for any spaces before or after email addresses
    • Verify all email addresses are valid

Debug Mode

Enable debug mode in Node-RED to see detailed logs:

  1. Open Node-RED settings
  2. Enable debug mode
  3. Deploy and check debug messages

License

MIT

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Node Info

Version: 1.0.5
Updated 1 week, 2 days ago
Rating: not yet rated

Categories

Actions

Rate:

Downloads

108 in the last week

Nodes

  • email-node
  • email-config

Keywords

  • node-red
  • email
  • file
  • attachment

Maintainers