node-red-contrib-email
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "node-red-contrib-email", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "SMTP email node for Node-RED", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,2 +5,8 @@ # node-red-contrib-email | ||
[![npm version](https://img.shields.io/npm/v/node-red-contrib-email.svg?style=flat-square)](https://www.npmjs.org/package/node-red-contrib-email) | ||
[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=node-red-contrib-email&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=node-red-contrib-email) | ||
[![npm downloads](https://img.shields.io/npm/dm/node-red-contrib-email.svg?style=flat-square)](https://npm-stat.com/charts.html?package=node-red-contrib-email) | ||
![node-email-send](https://raw.githubusercontent.com/steineey/node-red-contrib-email/master/examples/node-email-send.png) | ||
## Installation | ||
@@ -26,2 +32,3 @@ | ||
- **auth** - authentication 'none' or 'login' | ||
- **proxy** - is a proxy URL, for example 'http://proxy-host:1234' | ||
@@ -35,16 +42,17 @@ ## Send Mail Node Input | ||
- **subject** - The subject of the email | ||
### Message Payload | ||
`msg.payload` can be used for one of the following message versions. Set the node property *payload type* to set the version of your `msg.payload`. | ||
- **text** - The plaintext version of the message as an Unicode string, Buffer, Stream or an attachment-like object ({path: ‘/var/data/…'}) | ||
- **html** - The HTML version of the message as an Unicode string, Buffer, Stream or an attachment-like object ({path: ‘http://…'}) | ||
- **attachments** - An array of attachment objects (see [Using attachments](https://nodemailer.com/message/attachments/) for details). Attachments can be used for embedding images as well. | ||
- **amp** - AMP4EMAIL specific HTML version of the message, same usage as with text and html. See AMP example below for usage or this [blogpost](https://blog.nodemailer.com/2019/12/30/testing-amp4email-with-nodemailer/) for sending and rendering. | ||
`msg.payload` will used as mail.text or mail.html, depending on `content-type` field is set to text, html or amp. | ||
### Attachments | ||
Use the node form to define the fields or let the form fields empty and use `msg.email` instead: | ||
Set `msg.email.attachments` as an array of attachment objects (see [Using attachments](https://nodemailer.com/message/attachments/) for details). Attachments can be used for embedding images as well. | ||
```js | ||
msg.email = { | ||
from: "foo@example.com", | ||
to: "bar@example.com", | ||
subject: "Test", | ||
text: "This is my mail", | ||
attachments: [ | ||
@@ -108,6 +116,34 @@ { | ||
example for amp message | ||
### Overwrite Node Properties | ||
Use the node editor to define the email fields or overwrite this properties with a flow msg: | ||
```js | ||
msg.email = { | ||
from: "foo@example.com", | ||
to: "bar@example.com", | ||
subject: "Test", | ||
text: "This is the plain text version.", | ||
html: "<h1>This is the html version</h1>", | ||
attachments: [ | ||
{ | ||
// utf-8 string as an attachment | ||
filename: "text1.txt", | ||
content: "hello world!", | ||
} | ||
], | ||
}; | ||
``` | ||
Only overwrite email.to: | ||
```js | ||
msg.email = { | ||
to: "receiver@example.com" | ||
}; | ||
``` | ||
Example for amp message: | ||
```js | ||
msg.email = { | ||
from: "Nodemailer <example@nodemailer.com>", | ||
@@ -164,3 +200,2 @@ to: "Nodemailer <example@nodemailer.com>", | ||
- Proxy Support | ||
- OAuth2 authentication | ||
@@ -167,0 +202,0 @@ - Pooled SMTP |
@@ -12,2 +12,3 @@ module.exports = function (RED) { | ||
secure: config.secure, | ||
proxy: config.proxy || undefined | ||
}); | ||
@@ -46,2 +47,4 @@ | ||
let firstInput = false; | ||
// verify connection configuration | ||
@@ -56,3 +59,6 @@ transporter.verify(function (error, success) { | ||
}); | ||
} else { | ||
return; | ||
} | ||
if(!firstInput) { | ||
node.status({ | ||
@@ -68,2 +74,4 @@ fill: "green", | ||
firstInput = true; | ||
// set node status | ||
@@ -78,7 +86,7 @@ node.status({ | ||
const mail = { | ||
from: config.from || m.from, | ||
to: config.to || m.to, | ||
cc: config.cc || m.cc, | ||
bcc: config.bcc || m.bcc, | ||
subject: config.subject || m.subject, | ||
from: m.from || config.from, | ||
to: m.to || config.to, | ||
cc: m.cc || config.cc, | ||
bcc: m.bcc || config.bcc, | ||
subject: m.subject || config.subject, | ||
attachments: m.attachments, | ||
@@ -85,0 +93,0 @@ text: m.text, |
Sorry, the diff of this file is not supported yet
35133
6
113
201