# Node-red-node-email - allow msg.userid & msg.password

**URL:** <https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131>\
**Category:** Feature Requests\
**Created:** [30 July 2021 21:45 UTC](https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131 "2021-07-30T21:45:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [30 July 2021 21:45 UTC](https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131/1 "2021-07-30T21:45:57Z")

</div>

I have a Page (on a secured server with secure user login) and needed for the admin to be able to submit the userid and password via a msg and not with the built in credentials. Also Enable/Disable the TLS and Use secure connection options via msg.tls (boolean) and msg.secureconnection (boolean). Also added msg.port as well

Ive updated and tested the node is working for me with these changes but wonder if it has any use as a PR or should I just create a contrib off shoot? Working on the documentation now. Let me know if you want it as a PR.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [30 July 2021 22:51 UTC](https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131/2 "2021-07-30T22:51:48Z")

</div>

```auto
this.on("input", function(msg, send, done) {
            if (msg.hasOwnProperty("payload")) {
                send = send || function() { node.send.apply(node,arguments) };
                if (msg.userid || msg.password || msg.tls === true || msg.tls === false || msg.secureconnection === true || msg.secureconnection === false || msg.port) {
                    if (msg.userid && msg.password) { //User specified userid & password via message
                        smtpOptions.auth = {
                          user: msg.userid,
                          pass: msg.password
                        };
                    }
                    if (msg.tls === true || msg.tls === false) { //User specified tls boolean via message
                        smtpOptions.tls.rejectUnauthorized = msg.tls;
                    }
                    if (msg.secureconnection === true || msg.secureconnection === false) { //User specified secureconnection boolean via message
                        smtpOptions.secure = msg.secureconnection;
                    }
                    if (msg.port) {
                        smtpOptions.port = parseInt(msg.port, 10); //User specified port via message
                    }
                    smtpTransport = nodemailer.createTransport(smtpOptions);
                }

```

the only issue i see is it does add a little overhead because it has to createTransport for nodemailer each time vs having it stored.

---

<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:** [31 July 2021 07:50 UTC](https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131/3 "2021-07-31T07:50:05Z")

</div>

The default pattern we use is that if configured then use the value in the node. Only allow msg properties if the option is blank.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [31 July 2021 08:00 UTC](https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131/4 "2021-07-31T08:00:54Z")

</div>

So your saying shamaybe to a PR if I code it up to only allow msg properties if the option is blank....Got ya 🙂 I'll get working on it.

---

<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:** [31 July 2021 08:03 UTC](https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131/5 "2021-07-31T08:03:21Z")

</div>

Yes. But it’s not that simple :-). Some of those options are checkboxes so can’t be left blank.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [31 July 2021 08:10 UTC](https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131/6 "2021-07-31T08:10:07Z")

</div>

It would look funny but I could put drop-down on those of enable, disable, msg.tls ???? I just wonder how many other users are in my boat ......... Ive never seen a request for what im doing.... might be best to bring its as close to your standards and make a contrib and keep it up to date with the official node. If and when you get people asking for what im doing then we can just do a PR then.

Hey It did make me want to fix the documentation on the official node so there is that 😛

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 September 2021 08:10 UTC](https://discourse.nodered.org/t/node-red-node-email-allow-msg-userid-msg-password/49131/7 "2021-09-29T08:10:34Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
