Node-red-node-email headers format

G'day,
I was wanting to add a header in an email sent via the node-red-node-email node but I am having trouble with the format of the headers element.

I have tried both a simple string "X-header-name: value" and a JSON object {"X-header-name": "value"} but they are not coming through with the email.

Is there some other format that the underlying nodemailer library is requiring?

Thanks for any input on this.

Reading the help text the "X-header-name" should be sent in msg.headers
eg
in a change node
set msg. headers["X-header-name"]
to value string value

In a function node

msg.headers = {};
msg.headers["X-header-name"] = "value";
return msg;

Thanks @E1cid
I tried a setting the header in that way in an inject node and also in a function node.
Both present like this in a debug:

headers: object
    X-header-name: "value"

But the header is not included in the email received.

Quite strange.

Could you try something:

  1. Edit your email node & remove the email address.
  2. In your function, set msg.to = "the_email@address" (where the_email@address is the email removed from step 1)

I don't know why but it seems headers won't be sent if the to field is set: node-red-nodes/social/email/61-email.js at ea48b6acdd469d8c790503459c3f96994e3eab9b · node-red/node-red-nodes · GitHub

@dceejay any thoughts on this ^?

TBH. No idea. Must have been a reason back in the mists of time…. But can’t recall now.

1 Like

G'day Steve,

Thanks for the suggestion.
That works.

Regards,
Christopher