# Can send e-mail but the message is undefined

**URL:** https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021
**Category:** General
**Created:** [31 October 2021 19:29 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021 "2021-10-31T19:29:49Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![KrisJeff](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@KrisJeff](https://discourse.nodered.org/u/KrisJeff)
#### Post date: [31 October 2021 19:29 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/1 "2021-10-31T19:29:49Z")

</div>

Can send a basic e-mail from the e-mail out node. Upon receiving the e-mail I get the Topic and no message. However, I just get "undefined"? This is the simplest of flows and should work as per examples? Help!

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [31 October 2021 19:46 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/2 "2021-10-31T19:46:47Z")

</div>

Using a debug node, see what is being passed in to the email node.

---

<div class="post-metadata">

### Author: ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)
#### Post date: [1 November 2021 07:59 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/3 "2021-11-01T07:59:38Z")

</div>

what is the output of msg.payload in the debug node?

---

<div class="post-metadata">

### Author: ![KrisJeff](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@KrisJeff](https://discourse.nodered.org/u/KrisJeff)
#### Post date: [1 November 2021 09:27 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/4 "2021-11-01T09:27:04Z")

</div>

Here is the flow.

[  
{  
"id": "616829be3604ee04",  
"type": "tab",  
"label": "Flow 1",  
"disabled": false,  
"info": ""  
},  
{  
"id": "cb0469e476ae8a95",  
"type": "rpi-gpio in",  
"z": "616829be3604ee04",  
"name": "",  
"pin": "7",  
"intype": "down",  
"debounce": "25",  
"read": false,  
"x": 70,  
"y": 220,  
"wires": [  
[  
"3e1ce9e1468d2442"  
]  
]  
},  
{  
"id": "be94b59f4b942cba",  
"type": "debug",  
"z": "616829be3604ee04",  
"name": "",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "false",  
"statusVal": "",  
"statusType": "auto",  
"x": 950,  
"y": 300,  
"wires":   
},  
{  
"id": "6551a849330b0282",  
"type": "e-mail out",  
"z": "616829be3604ee04",  
"server": "[smtp.mail.yahoo.com](http://smtp.mail.yahoo.com)",  
"port": "465",  
"secure": true,  
"name": "[krisjeffs1@gmail.com](mailto:krisjeffs1@gmail.com)",  
"dname": "E-mail Out",  
"x": 710,  
"y": 300,  
"wires": [  
[  
"be94b59f4b942cba"  
]  
]  
},  
{  
"id": "75c12fe9c72a0546",  
"type": "function",  
"z": "616829be3604ee04",  
"name": "Node Red Alarm",  
"func": "msg = {\n payload : "Alarm has been triggered at " + Date().toString(),\n topic : "Emergency Trigger!",\n\n}\nreturn msg;",  
"outputs": 1,  
"noerr": 0,  
"initialize": "",  
"finalize": "",  
"libs": ,  
"x": 420,  
"y": 220,  
"wires": [  
[  
"6551a849330b0282"  
]  
]  
},  
{  
"id": "3e1ce9e1468d2442",  
"type": "switch",  
"z": "616829be3604ee04",  
"name": "",  
"property": "payload",  
"propertyType": "msg",  
"rules": [  
{  
"t": "eq",  
"v": "1",  
"vt": "num"  
}  
],  
"checkall": "true",  
"repair": false,  
"outputs": 1,  
"x": 230,  
"y": 220,  
"wires": [  
[  
"75c12fe9c72a0546"  
]  
]  
},  
{  
"id": "1c3b130691948fdb",  
"type": "inject",  
"z": "616829be3604ee04",  
"name": "",  
"props": [  
{  
"p": "payload"  
},  
{  
"p": "topic",  
"vt": "str"  
}  
],  
"repeat": "",  
"crontab": "",  
"once": false,  
"onceDelay": 0.1,  
"topic": "Alarm Tripped",  
"payloadType": "str",  
"x": 400,  
"y": 300,  
"wires": [  
[  
"6551a849330b0282"  
]  
]  
}  
]

Here is the debug:  
11/1/2021, 10:24:30 AM[node: be94b59f4b942cba](http://192.168.0.176:1880/#)Emergency Trigger! : msg.payload : string[94]

"Alarm has been triggered at Mon Nov 01 2021 10:24:27 GMT+0100 (Central European Standard Time)"

11/1/2021, 10:24:56 AM[node: be94b59f4b942cba](http://192.168.0.176:1880/#)Alarm Tripped : msg.payload : string[0]

""

---

<div class="post-metadata">

### Author: ![KrisJeff](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@KrisJeff](https://discourse.nodered.org/u/KrisJeff)
#### Post date: [1 November 2021 09:44 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/5 "2021-11-01T09:44:27Z")

</div>

Up dated flow:

```auto
[
{
"id": "1c3b130691948fdb",
"type": "inject",
"z": "616829be3604ee04",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "Alarm Tripped",
"payload": "Alarm Tripped",
"payloadType": "str",
"x": 440,
"y": 300,
"wires": [
[
"6551a849330b0282"
]
]
}
]

```

Here is the debug:

1-11/1/2021, 10:34:37 AM[node: be94b59f4b942cba](http://192.168.0.176:1880/)Alarm Tripped : msg.payload : string[13]  
"Alarm Tripped"  
2-11/1/2021, 10:39:11 AM[node: be94b59f4b942cba](http://192.168.0.176:1880/)Emergency Trigger! : msg.payload : string[94]  
"Alarm has been triggered at Mon Nov 01 2021 10:39:09 GMT+0100 (Central European Standard Time)"

Simple flow yet no message only Topic?

Using email out node: node-red-contrib-email-out. Tried alternative node-red-node-email but I can’t get this to work at all

Using the same e-mail setup?

Kind regards,

Kris.

 ![1DBDCCB5B6C74A51A4340270580B4443.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/7159a975d714a6caee787759490140daf4d4fda6.png)

---

<div class="post-metadata">

### Author: ![KrisJeff](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@KrisJeff](https://discourse.nodered.org/u/KrisJeff)
#### Post date: [1 November 2021 09:48 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/6 "2021-11-01T09:48:23Z")

</div>

![580C3FDEAA084B72AD597287A4BA7BB1.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/c/bcf5bb0c9c3dfa5751a2f80a91164a9125e995bd.png)

 ![1DBDCCB5B6C74A51A4340270580B4443.png](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/7159a975d714a6caee787759490140daf4d4fda6.png)

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [1 November 2021 10:27 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/7 "2021-11-01T10:27:38Z")

</div>

Kris, why are you using the `node-red-contrib-email-out` node? It hasn't been updated since May of 2017.

What is wrong with `node-red-node-email`?

Also, in order to make code more readable and importable it is important to surround your code with three backticks  
`````  
`like this`  
`````

You can edit and correct your post by clicking the pencil icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![KrisJeff](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@KrisJeff](https://discourse.nodered.org/u/KrisJeff)
#### Post date: [1 November 2021 10:36 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/8 "2021-11-01T10:36:16Z")

</div>

node-red-contrib-email-out will send e-mail with the topic but no message (undefined). I tried the node-red-node-email with the same e-mail setting but couldn't get it to work at all? At least I can send an email with the email out. I must have something wrong in my set up? I will re-visit the node you suggest.  
Regarding surrounding code with backticks I'm no coder and just copied code I found in tutorials.

Kris.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [1 November 2021 10:50 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/9 "2021-11-01T10:50:17Z")

</div>

> [@KrisJeff](#):
>
> Regarding surrounding code with backticks I'm no coder and just copied code I found in tutorials.

This is why I pointed out how to do it and refered you to the thread for posting.

When you use `node-red-node-email` are you seeing any error? You could add a `catch` node connected to a `debug` node (set to display the complete msg object) and see if there is an error

---

<div class="post-metadata">

### Author: ![KrisJeff](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@KrisJeff](https://discourse.nodered.org/u/KrisJeff)
#### Post date: [1 November 2021 14:44 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/10 "2021-11-01T14:44:14Z")

</div>

Solved. E-mail client problem. Used alternative email node as suggested. I forgot to use the one time password for node red to send email via Yahoo. (Needs Yahoo generated one off password for Node Red) The node-red-contrb-email-out node would send the e-mail with the Topic but not the message.  
Once I'd switched to the email node as suggested, and entered the one off password, Bingo!  
Thanks to all for your guidance.  
Kris.

---

<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: [15 November 2021 14:45 UTC](https://discourse.nodered.org/t/can-send-e-mail-but-the-message-is-undefined/53021/11 "2021-11-15T14:45:13Z")

</div>

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