Add cc and bcc options to email node

to close #209
This commit is contained in:
Dave Conway-Jones 2016-06-03 16:14:20 +01:00
parent 4248b580ee
commit b6f45ef8d4
3 changed files with 17 additions and 12 deletions

View File

@ -71,13 +71,14 @@
<script type="text/x-red" data-help-name="e-mail"> <script type="text/x-red" data-help-name="e-mail">
<p>Sends the <code>msg.payload</code> as an email, with a subject of <code>msg.topic</code>.</p> <p>Sends the <code>msg.payload</code> as an email, with a subject of <code>msg.topic</code>.</p>
<p>The default message recipient can be configured in the node, if it is left <p>The default message recipient can be configured in the node, if it is left
blank it should be set using the <code>msg.to</code> property of the incoming message.</p> blank it should be set using the <code>msg.to</code> property of the incoming message. If left blank
you can also specify <code>msg.cc</code> and/or <code>msg.bcc</code> properties.</p>
<p>The payload can be html format.</p> <p>The payload can be html format.</p>
<p>If the payload is a binary buffer then it will be converted to an attachment. <p>If the payload is a binary buffer then it will be converted to an attachment.
The filename should be set using <code>msg.filename</code>. Optionally <code>msg.description</code> can be added for the body text.</p> The filename should be set using <code>msg.filename</code>. Optionally <code>msg.description</code> can be added for the body text.</p>
<p>Alternatively you may provide <code>msg.attachments</code> which should contain an array of one or <p>Alternatively you may provide <code>msg.attachments</code> which should contain an array of one or
more attachments in <a href="https://www.npmjs.com/package/nodemailer#attachments" target="_new">nodemailer</a> format.</p> more attachments in <a href="https://www.npmjs.com/package/nodemailer#attachments" target="_new">nodemailer</a> format.</p>
<p>If required by your recipient you may also pass in a <code>msg.envelope</code> object, typically containing extra from and to properties.</p> <p>If required by your recipient you may also pass in a <code>msg.envelope</code> object, typically containing extra from and to properties.</p>
<p>Note: uses SMTP with SSL to port 465.</p> <p>Note: uses SMTP with SSL to port 465.</p>
</script> </script>

View File

@ -88,6 +88,10 @@ module.exports = function(RED) {
} }
var sendopts = { from: node.userid }; // sender address var sendopts = { from: node.userid }; // sender address
sendopts.to = node.name || msg.to; // comma separated list of addressees sendopts.to = node.name || msg.to; // comma separated list of addressees
if (node.name === "") {
sendopts.cc = msg.cc;
sendopts.bcc = msg.bcc;
}
sendopts.subject = msg.topic || msg.title || "Message from Node-RED"; // subject line sendopts.subject = msg.topic || msg.title || "Message from Node-RED"; // subject line
if (msg.hasOwnProperty("envelope")) { sendopts.envelope = msg.envelope; } if (msg.hasOwnProperty("envelope")) { sendopts.envelope = msg.envelope; }
if (Buffer.isBuffer(msg.payload)) { // if it's a buffer in the payload then auto create an attachment instead if (Buffer.isBuffer(msg.payload)) { // if it's a buffer in the payload then auto create an attachment instead

View File

@ -1,21 +1,21 @@
{ {
"name" : "node-red-node-email", "name" : "node-red-node-email",
"version" : "0.1.6", "version" : "0.1.7",
"description" : "Node-RED nodes to send and receive simple emails", "description" : "Node-RED nodes to send and receive simple emails",
"dependencies" : { "dependencies": {
"nodemailer" : "1.11.*", "nodemailer": "^1.11.0",
"poplib" : "0.1.7", "poplib": "^0.1.7",
"mailparser" : "0.5.3", "mailparser": "^0.5.3",
"imap" : "0.8.17" "imap": "^0.8.17"
}, },
"repository" : { "repository": {
"type":"git", "type": "git",
"url":"https://github.com/node-red/node-red-nodes/tree/master/social/email" "url":"https://github.com/node-red/node-red-nodes/tree/master/social/email"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"keywords": [ "node-red", "email", "gmail", "imap" ], "keywords": [ "node-red", "email", "gmail", "imap" ],
"node-red" : { "node-red": {
"nodes" : { "nodes": {
"email": "61-email.js" "email": "61-email.js"
} }
}, },