Email node sending as attachment instead of html

So I've noticed some strange behaviour which I can't pinpoint why is happening.
I am using an email node to send emails. My payload is html content.

When I specify the "to" field in the email node itself, the email is sent correctly.

If I specify msg.to in any previous node (and clear the "to" field in the email node), then all of the content of the email shows up as an attachment and the email body is completely empty.

Any idea what could be going on?

Thanks,
P

Try : msg.to = ["youraddress@.email.com"]

You can set multiple recipients

I've tried that with a function node just now. Array works in defining multiple addresses. However, the email body is still sent as an attachment instead of an actual html email.

Try this, in function node (just before email node)

msg.payload = "Email Body";
msg.to = ["youraddress@.email.com"];
msg.topic = "Topic Msg";
msg.attachments = [ ];

A minimal example works but it doesn't work in my flow. It's odd. I'll try shifting around stuff to see that happens.

Versions of NodeRed, email Node, NodeJs ?

node-red: 3.0.2
email node: 1.18.4

Not sure how to get node.js version, literally just installed NR a few days ago, sorry!

In console, type : node -v

I use 16.19.0 (I don't changed to version 18)

Mine would be 16.16.0

I just figured out that if I clear out the msg. content and then create the array, the email node works. So some parameter is messing up my node. I'll come back in a bit and report.

Take a look here : Attachments :: Nodemailer

So I think the problem might have been caused by a msg.headers which was carried over by an http request node. I am not sure.

The problem is anyhow resolved by clearing the msg variable and rebuilding it in the function node.

Thanks for your help, hopefull I will learn what exactly caused it and not repeat it again!

You could try using a change node and delete that element from the msg

1 Like

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