Proposed change to mail node - set config via input / config node

Hello,

I’d like to propose a change. According to the contribution guide, I’m opening this thread to discuss it first.

I'm a developer using Node-RED in an enterprise environment, where we have CI/CD pipelines, deployments, and multiple environments with many flows and nodes in each.

Currently, the mail nodes (for sending and receiving emails) aren't well-suited for automatic deployment:

  • Both nodes lack a configuration node.

  • You can't set the node’s configuration (such as credentials) via input. (The mail fetch node doesn’t even have an input.)

  • Credentials provided via the UI aren't persisted in the node.

As a result, after each deployment, we have to manually re-enter the credentials in every mail node via the UI - which is quite tedious.

My actual suggestion is to allow setting the configuration of mail nodes - particularly credentials -via input. In my opinion, this has an advantage over using a config node, as it allows for more dynamic behavior. For example, you could fetch emails from different folders or accounts in a rotating or conditional manner.

We’ve already built custom subflows for sending and receiving emails (using nodemailer/imap), but we believe it would be better to propose this as a feature request or pull request (PR) to the mail node itself.

I’d be happy to submit a PR with the necessary changes, if there's interest. If changes to the core mail node aren’t desired, please let me know how I can otherwise achieve persisted credentials.

Greetings,

2 Likes

Have you checked the flow library

PR request are always welcome.

I use environmental variables to feed MySQL user id and password, may be some thing similar should work for email - node as well ?

1 Like

As a workaround, you could pre-process your flows.json in your CICD pipeline to update these email nodes entries to certain values depending on the environment.

What exactly do you mean by this?

Credentials should always be persisted as credentials (stored encrypted in a separate file, normally flows_creds.json) not node properties in the flow file and the email nodes do this correctly.

Also both the username and password can be set to be read from environment variables at flow start using the ${ENV_NAME} syntax as described here:

1 Like