# Email login/password setup

**URL:** <https://discourse.nodered.org/t/email-login-password-setup/77213>\
**Category:** General\
**Created:** [3 April 2023 22:25 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213 "2023-04-03T22:25:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [3 April 2023 22:25 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/1 "2023-04-03T22:25:36Z")

</div>

configuring userid and password via environmental variables works fine....for a while, when they just disappear from email node. Only applying then manually (using environment format) would restart the authentication process.

tried then 'node-red-node-email-variable' that allegedly allows sensing userid and password, but has not worked for me

Suggestions?

Thanks

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [4 April 2023 06:27 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/2 "2023-04-04T06:27:55Z")

</div>

> [@calixtoemilio](#):
>
> when they just disappear from email node.

What do you mean by disappear ? The flow won’t change unless you edit it.

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [4 April 2023 13:18 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/3 "2023-04-04T13:18:58Z")

</div>

That is the thing, those two fields, 'Userid' and 'Password' all of the sudden show up empty.

the uniqueness of my case is that they don't contain strings (hidden behind dots in 'Password') but referencing environmental variables, sort of ${EMAIL\_USERID} or ${EMAIL\_PASSWORD}

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 April 2023 20:18 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/4 "2023-04-04T20:18:54Z")

</div>

> [@calixtoemilio](#):
>
> those two fields, 'Userid' and 'Password' all of the sudden show up empty.

Did you copy and paste the node, or something like that. Move it to a different tab for example?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 April 2023 20:33 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/5 "2023-04-04T20:33:45Z")

</div>

If not that then possibly you accidentally changed the credential secret.

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [4 April 2023 21:11 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/6 "2023-04-04T21:11:23Z")

</div>

Well, this is server we run on a daily basis and is under constant development.

That happens every single time I launch the container. It not like accidentally, happens always.

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [4 April 2023 21:39 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/7 "2023-04-04T21:39:38Z")

</div>

btw, I have the development instance plus another testing platform for email only.

In the latter I I am trying '[node-red-node-email-variable (node) - Node-RED](https://flows.nodered.org/node/node-red-node-email-variable)' that allegedly allows passing userid + password. But is not working. That is my second failing scenario

Thanks

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 April 2023 07:53 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/8 "2023-04-05T07:53:42Z")

</div>

Check the node red log on initial startup after container launch and see if there is anything there about the credentials.

How have you specified the credential secret?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 April 2023 20:26 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/9 "2023-04-05T20:26:39Z")

</div>

Also, I should have asked earlier, do you lose credentials in all nodes that have credentials (if there are any) or is the email node the only one?

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [9 May 2023 21:39 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/10 "2023-05-09T21:39:38Z")

</div>

been monitoring for a while in two instances

at some moment credentials are gone

they are passes during building the docker container as ENV variables, sort of

[EMAIL\_USERID=cws@xxxxxxxx.com](mailto:EMAIL_USERID=cws@xxxxxxxx.com)   
EMAIL\_PASSWORD=abababababa56r! \

then inserted in the node as  
${EMAIL\_USERID}  
${EMAIL\_PASSWORD}

still they vanished are email node stops rightly authenticating

curiously in the flows.json the email node looks as

```
{
    "id": "2f451839a5dcbe7f",
    "type": "e-mail",
    "z": "fce1fe3f02b694d8",
    "server": "${EMAIL_SERVER}",
    "port": "${EMAIL_PORT}",
    "secure": true,
    "tls": true,
    "name": "${TO_EMAIL}",
    "dname": "Email sender",
    "output": false,
    "outputs": 0,
    "x": 770,
    "y": 2960,
    "wires": []
},

```

'user\_id' and 'password' are not part of node description...

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [9 May 2023 21:41 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/11 "2023-05-09T21:41:42Z")

</div>

> [@calixtoemilio](#):
>
> still they vanished are email node stops rightly authenticating

"they are passes" =\>"they are passed while building docker container"  
"still they vanished are email node stops rightly authenticating" = \> "still they vanish AND email node stops ..."

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [10 May 2023 05:28 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/12 "2023-05-10T05:28:44Z")

</div>

> [@calixtoemilio](#):
>
> That happens every single time I launch the container. It not like accidentally, happens always.

Well I guess you are not only restarting the container but recreating the container. Probably that destroys the environment variable. How do you define it?

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [10 May 2023 15:26 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/13 "2023-05-10T15:26:08Z")

</div>

Not exactly. Container is created then deployed.

Once deployed and functional, at some point, randomly, the email node loses the authentication information (email account and password) and from that point, mail delivery fails

I need to reenter again user+password...using the original values or the environment reference ${EMAIL\_USERID} and ${EMAIL\_PASSWORD}

It is about the email node losing that piece of the configuration only

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 May 2023 15:44 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/14 "2023-05-10T15:44:00Z")

</div>

Are you absolutely certain that it does not get recreated in the meantime?  
What do you see in the node-red log between when it works and when it doesn't?  
You could add some nodes monitoring the env vars to find out exactly when they disappear so that you can home in on the right time in the log.

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [11 May 2023 07:35 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/15 "2023-05-11T07:35:03Z")

</div>

I assume to make anything meaningful out of it you should get some logs or investigate to get more details.

I am using the node with IMAP and gmail and the credentials are in there for way over a year now.

Are you using Oauth? Maybe the token expires?  
What is the timespan between the node loosing credentials?  
Did you check if the credentials vanish if you put them in there directly? (If you are allowed to test this.)  
Once the credentials vanish, did you open a shell to the container and check if the env is still there?

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [11 May 2023 19:11 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/16 "2023-05-11T19:11:32Z")

</div>

Are You using a docker nodered container?

about the env presistence.

yes, they are there. I have this node to print out current env variables.

Curiously, when i reenter the env references (${EMAIL\_USERID} and ${EMAIL\_PASSWORD}), the email node start working again. That happens by restarting the changed node (email) inside nodered. Even if I restarted the whole nodered flows, it does not restart the docker container

Now, this is very telling  
{  
"id": "2f451839a5dcbe7f",  
"type": "e-mail",  
"z": "fce1fe3f02b694d8",  
"server": "${EMAIL\_SERVER}",  
"port": "${EMAIL\_PORT}",  
"secure": true,  
"tls": true,  
"name": "${TO\_EMAIL}",  
"dname": "Email sender",  
"output": false,  
"outputs": 0,  
"x": 770,  
"y": 2960,  
"wires":   
},

this is node description just after adding again ${EMAIL\_USERID} and ${EMAIL\_PASSWORD}

how do You inject user\_id and password?

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [11 May 2023 19:59 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/17 "2023-05-11T19:59:25Z")

</div>

> [@calixtoemilio](#):
>
> Are You using a docker nodered container?

👍 I run node-red in docker only. Its so easy to test things... Few clicks and a fresh node-red instance is created from a template.

Just gave it a whirl and for me this seems to work.

```auto
version: '3'

services:    
  nodered:
    image: nodered/node-red
    environment:
      - TZ=Europe/Berlin
      - EMAIL_USER=${env_EMAIL_USER}
      - EMAIL_PASSWORD=${env_EMAIL_PASSWORD}
    dns:
      - 1.1.1.1
      - 8.8.8.8
    ports:
      - 1880
    restart: always #unless-stopped
    labels:
      com.centurylinklabs.watchtower.enable: "true"

```

Inside the container both environment variables are defined.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/a/9a7ba5801027dc9e63fef4992cd0b62a2a96da0f.png)  
The node `criteria` only defines some criteria because I do not want to retrieve hundreds of messages for every click. 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b1b39a9e5732718db24827ca15407d029e058978.png)

This survived redeployment in node-red and even stopping and starting of the container.

And yes it is true, that both user and password are not exported. Guess that is even a good thing.

````auto
[
    {
        "id": "21edb18484a2380e",
        "type": "e-mail in",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "protocol": "IMAP",
        "server": "imap.gmail.com",
        "useSSL": true,
        "autotls": "required",
        "port": "993",
        "authtype": "BASIC",
        "saslformat": true,
        "token": "oauth2Response.access_token",
        "box": "wss_export",
        "disposition": "None",
        "criteria": "_msg_",
        "repeat": "300",
        "fetch": "trigger",
        "inputs": 1,
        "x": 870,
        "y": 260,
        "wires": [
            [
                "33522b3af9c18ed8",
                "64cb2f96c43dfd50"
            ]
        ]
    }
]```
````

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [11 May 2023 21:12 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/18 "2023-05-11T21:12:07Z")

</div>

Thanks!!, very interesting.

See You are using Docker Composer. Since I did not find a path from docker container, to docker composer .yaml to kubernetes, I skipped the Composer step.

Maybe Composer adds some minor architectural changes, but now I believe the problem is somewhere else.

First, I cannot find a reason that having ${EMAIL\_PASSWORD} in the flow.json file would open a security hole.

Here is my development cycle. I use git for version control. After any changes, I download flow.json into my desktop, and using Visual Studio push it to git repository. On whatever linux instance will use, pull the code from the git repository (various Dockefile versions, flow.json, package.json, server.js and setting.js)

Then build the container file using the right Dockerfile and lunch it in docker. If ${EMAIL\_USERID} and ${EMAIL\_PASSWORD} are missed in flow.json, no way it can be applied to new container.

Then, there is this package

> **[node-red-node-email-variable](https://flows.nodered.org/node/node-red-node-email-variable)**
>
> Node-RED nodes to send and receive simple emails.

that allegedly configure the email node by feeding configuration parameter into the input. It never worked for me ☹

I will look carefully into the whole code flow, to validate if it fails upon uploading a new version.

Will try IMAP as well.

Again, Thank You!!, your experience is very important to me

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 May 2023 08:07 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/19 "2023-05-12T08:07:51Z")

</div>

> [@calixtoemilio](#):
>
> If ${EMAIL\_USERID} and ${EMAIL\_PASSWORD} are missed in flow.json, no way it can be applied to new container.

Provided you include the credentials file in the repo (and set the encryption password by some appropriate means) then it will work. The same would apply, for example, to MQTT security details and so on.

---

<div class="post-metadata">

**Author:** ![calixtoemilio](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@calixtoemilio](https://discourse.nodered.org/u/calixtoemilio)\
**Post date:** [12 May 2023 13:38 UTC](https://discourse.nodered.org/t/email-login-password-setup/77213/20 "2023-05-12T13:38:04Z")

</div>

I pass credentials in 2 other cases: MQTT and Postgresql

In Both cases are passed as environment variables into 'configuration nodes'. But Email is not a configuration node.

I use the Dockerfile to pass environment variable like  
ENV DB\_NAME=db\_username   
DB\_USER=db\_password   
EMAIL\_PASSWORD=my\_email\_password   
...

For instance, right from 'flows.json':

{  
"id": "5925e1f25d39f49d",  
"type": "postgreSQLConfig",  
"name": "RDS-Development R/O",  
"host": "${DB\_RO\_HOST}",  
"hostFieldType": "str",  
"port": "5432",  
"portFieldType": "num",  
"database": "${DB\_NAME}",  
"databaseFieldType": "str",  
"ssl": "false",  
"sslFieldType": "bool",  
"max": "10",  
"maxFieldType": "num",  
"min": "",  
"minFieldType": "",  
"idle": "1000",  
"idleFieldType": "num",  
"connectionTimeout": "10000",  
"connectionTimeoutFieldType": "num",  
"user": "${DB\_USER}",  
"userFieldType": "str",  
"password": "${DB\_PASSWORD}",  
"passwordFieldType": "str"  
},

I don't use local volumes in docker host as a persistent media, just where that data would remain stored upon restarting or launching a new node-red container. The reason is to facilitate deploying the migration to kubernetes. I did not find a way to migrate persistent volumes from docker to kubernetes.

I am sorry, I know I am missing something here, but trying to figure out what the missing link is. Thank You!!!

[Next page](https://discourse.nodered.org/t/email-login-password-setup/77213.md?page=2)
