Add support for separate plaintext in outgoing mails (#788)

* Add support for separate plaintext in outgoing mails

* Rename msg.plain to msg.plaintext
This commit is contained in:
Maximilian Gutwein
2021-03-31 21:51:43 +02:00
committed by GitHub
parent ef8d5bd8ee
commit 4697636055
3 changed files with 13 additions and 3 deletions

View File

@@ -119,7 +119,13 @@ module.exports = function(RED) {
else {
var payload = RED.util.ensureString(msg.payload);
sendopts.text = payload; // plaintext body
if (/<[a-z][\s\S]*>/i.test(payload)) { sendopts.html = payload; } // html body
if (/<[a-z][\s\S]*>/i.test(payload)) {
sendopts.html = payload; // html body
if (msg.hasOwnProperty("plaintext")) {
var plaintext = RED.util.ensureString(msg.plaintext);
sendopts.text = plaintext; // plaintext body - specific plaintext version
}
}
if (msg.attachments && Array.isArray(msg.attachments)) {
sendopts.attachments = msg.attachments;
for (var a=0; a < sendopts.attachments.length; a++) {