Can send e-mail but the message is undefined

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!

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

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

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",
"port": "465",
"secure": true,
"name": "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 AMnode: be94b59f4b942cbaEmergency 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 AMnode: be94b59f4b942cbaAlarm Tripped : msg.payload : string[0]

""

Up dated flow:

[
{
"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 AMnode: be94b59f4b942cbaAlarm Tripped : msg.payload : string[13]
"Alarm Tripped"
2-11/1/2021, 10:39:11 AMnode: be94b59f4b942cbaEmergency 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.

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

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.

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

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.

1 Like

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