node-red-contrib-email-dynamic 1.0.1

A Node-RED node to send emails. Both server settings and email details can be configured dynamically via the message payload.

npm install node-red-contrib-email-dynamic

node-red-contrib-email-dynamic

Description

This Node-RED node allows you to send emails with dynamic SMTP server settings and attachments. The node is designed to be flexible, allowing you to specify SMTP server configurations and email content dynamically through the payload, or to use static configurations set in the node itself. This can be particularly useful for sending emails from within Node-RED flows with varying configurations.

Features

  • Dynamic SMTP Configuration: Supports setting SMTP server settings dynamically via message payload or through node configuration.

  • Dynamic Attachments: Allows adding multiple attachments to the email dynamically via message payload.

  • HTML and Text Support: Supports both plain text and HTML email content.

  • Flexible Authentication: Supports basic authentication with username and password, or OAuth tokens.

Installation

To install this node, use the Node-RED Palette Manager or install it directly via npm:

npm install node-red-contrib-email-dynamic

Usage

You can configure the email sending details directly in the node or pass them dynamically through the payload. The node supports sending attachments and using both text and HTML content.

Configuration

Node Properties

  • SMTP Server: SMTP server address (e.g., smtp.example.com).

  • SMTP Port: SMTP server port (e.g., 587).

  • SMTP User: SMTP authentication username.

  • SMTP Password: SMTP authentication password.

  • Secure: Set to true if using SSL/TLS, otherwise false.

  • TLS Options: Configure TLS options if required.

Flow Example

Here is an example of how to use this node in a Node-RED flow:

[
    {
        "id": "21e185dded19e0ef",
        "type": "email-dynamic",
        "z": "dfaf710c44ca5279",
        "name": "",
        "smtpServer": "",
        "smtpPort": "",
        "smtpUser": "",
        "smtpPass": "",
        "secure": false,
        "tlsRejectUnauthorized": false,
        "x": 1860,
        "y": 620,
        "wires": [
            []
        ]
    },
    {
        "id": "eb8d297e425e2b38",
        "type": "inject",
        "z": "dfaf710c44ca5279",
        "name": "input",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 1530,
        "y": 620,
        "wires": [
            [
                "23bc26edc4890059"
            ]
        ]
    },
    {
        "id": "23bc26edc4890059",
        "type": "function",
        "z": "dfaf710c44ca5279",
        "name": "send email data",
        "func": "var content = Buffer.from(\"Example Text file.\").toString('base64');\n\nmsg.smtp = {\n    host: \"\",  // SMTP-Server\n    port: 587,                   // SMTP-Port\n    auth: {\n        user: \"\",   // SMTP-Benutzername\n        pass: \"\"    // SMTP-Passwort\n    },\n    secure: false,               // True für SSL/TLS\n    tls: {\n        rejectUnauthorized: false // Setze auf true, wenn du eine Zertifikatsüberprüfung erzwingen möchtest\n    }\n};\n\n// E-Mail Details\nmsg.from = \"[email protected]\";       // Absenderadresse\nmsg.to = \"[email protected]\";     // Empfängeradresse\nmsg.subject = \"Betreff der E-Mail\";    // Betreff der E-Mail\nmsg.text = \"Das ist der E-Mail-Inhalt.\"; // Textinhalt der E-Mail\nmsg.attachments = [\n    {\n    \"filename\": \"example.txt\",\n    \"content\": content,\n    \"encoding\": \"base64\"\n}\n]\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1680,
        "y": 620,
        "wires": [
            [
                "21e185dded19e0ef"
            ]
        ]
    }
]

Troubleshooting

  • Attachment Issues: Ensure attachments are correctly formatted and encoded. Use Base64 encoding for binary files and proper text encoding for text files.

  • SMTP Errors: Verify SMTP server settings and authentication credentials. Ensure your server allows connections from your IP and the credentials are correct.

  • Debugging: Check Node-RED logs for detailed error messages. Enable debug logging for the email node to get more insight into issues.

License

This node is licensed under the MIT License.

Node Info

Version: 1.0.1
Updated 8 months, 3 weeks ago
License: ISC
Rating: not yet rated

Categories

Actions

Rate:

Downloads

11 in the last week

Nodes

  • email-dynamic

Keywords

  • mail
  • email
  • payload
  • dynamic
  • node-red
  • node
  • node-red-contrib
  • dynamically
  • send

Maintainers