2015-06-13 19:46:07 +02:00
<!--
2015-07-15 00:03:46 +02:00
Copyright 2013, 2015 IBM Corp.
2015-06-13 19:46:07 +02:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
< script type = "text/x-red" data-template-name = "e-mail" >
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-name" > < i class = "fa fa-envelope" > < / i > < span data-i18n = "email.label.to" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "text" id = "node-input-name" placeholder = "email@address.com" >
< / div >
<!-- <div class="form - row">
< label for = "node-input-pin" > < i class = "fa fa-asterisk" > < / i > Service< / label >
< select type = "text" id = "node-input-pin" style = "width: 150px;" >
< option value = "-" disabled > < / option >
< option value = "DynectEmail" > DynectEmail< / option >
< option value = "Gmail" > Gmail< / option >
< option value = "hot.ee" > hot.ee< / option >
< option value = "Hotmail" > Hotmail< / option >
< option value = "iCloud" > iCloud< / option >
< option value = "mail.ee" > mail.ee< / option >
< option value = "Mail.Ru" > Mail.Ru< / option >
< option value = "Mailgun" > Mailgun< / option >
< option value = "Mailjet" > Mailjet< / option >
< option value = "Mandrill" > Mandrill< / option >
< option value = "Postmark" > Postmark< / option >
< option value = "QQ" > QQ< / option >
< option value = "QQex" > QQex< / option >
< option value = "SendGrid" > SendGrid< / option >
< option value = "SendCloud" > SendCloud< / option >
< option value = "SES" > SES< / option >
< option value = "Yahoo" > Yahoo< / option >
< option value = "yandex" > yandex< / option >
< option value = "Zoho" > Zoho< / option >
< / select >
< / div > -->
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-server" > < i class = "fa fa-globe" > < / i > < span data-i18n = "email.label.server" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "text" id = "node-input-server" placeholder = "smtp.gmail.com" >
< / div >
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-port" > < i class = "fa fa-random" > < / i > < span data-i18n = "email.label.port" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "text" id = "node-input-port" placeholder = "465" >
< / div >
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-userid" > < i class = "fa fa-user" > < / i > < span data-i18n = "email.label.userid" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "text" id = "node-input-userid" >
< / div >
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-password" > < i class = "fa fa-lock" > < / i > < span data-i18n = "email.label.password" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "password" id = "node-input-password" >
< / div >
< br / >
< div class = "form-row" >
2015-06-16 12:16:29 +02:00
< label for = "node-input-dname" > < i class = "fa fa-tag" > < / i > < span data-i18n = "node-red:common.label.name" > < / span > < / label >
< input type = "text" id = "node-input-dname" data-i18n = "[placeholder]node-red:common.label.name" >
2015-06-13 19:46:07 +02:00
< / div >
2015-06-16 11:36:19 +02:00
< div class = "form-tips" id = "node-tip" > < span data-i18n = "[html]email.tip.cred" > < / span > < / div >
2015-06-13 19:46:07 +02:00
< / script >
< script type = "text/x-red" data-help-name = "e-mail" >
2016-02-12 15:05:10 +01:00
< p > Sends the < code > msg.payload< / code > as an email, with a subject of < code > msg.topic< / code > .< / p >
2015-06-13 19:46:07 +02:00
< p > The default message recipient can be configured in the node, if it is left
2016-06-03 17:14:20 +02:00
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 >
2016-08-03 10:01:28 +02:00
< p > You may optionally set < code > msg.from< / code > in the payload which will override the < code > userid< / code >
default value.< / p >
2015-06-13 19:46:07 +02:00
< p > The payload can be html format.< / p >
< p > If the payload is a binary buffer then it will be converted to an attachment.
2016-02-12 15:05:10 +01:00
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
2015-06-13 19:46:07 +02:00
more attachments in < a href = "https://www.npmjs.com/package/nodemailer#attachments" target = "_new" > nodemailer< / a > format.< / p >
2016-06-03 17:14:20 +02:00
< 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 >
2016-02-26 22:59:43 +01:00
< p > Note: uses SMTP with SSL to port 465.< / p >
2015-06-13 19:46:07 +02:00
< / script >
< script type = "text/javascript" >
(function() {
RED.nodes.registerType('e-mail',{
category: 'social-output',
color:"#c7e9c0",
defaults: {
server: {value:"smtp.gmail.com",required:true},
port: {value:"465",required:true},
name: {value:""},
dname: {value:""}
},
credentials: {
userid: {type:"text"},
password: {type: "password"},
global: { type:"boolean"}
},
inputs:1,
outputs:0,
icon: "envelope.png",
align: "right",
label: function() {
return this.dname||this.name||"email";
},
labelStyle: function() {
return (this.dname||!this.topic)?"node_label_italic":"";
},
oneditprepare: function() {
if (this.credentials.global) {
$('#node-tip').show();
} else {
$('#node-tip').hide();
2015-06-16 15:38:36 +02:00
}
2015-06-13 19:46:07 +02:00
}
});
})();
< / script >
< script type = "text/x-red" data-template-name = "e-mail in" >
< div class = "form-row node-input-repeat" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-repeat" > < i class = "fa fa-repeat" > < / i > < span data-i18n = "email.label.repeat" > < / span > < / label >
< input type = "text" id = "node-input-repeat" style = "width: 80px" > < span data-i18n = "email.label.seconds" > seconds< / span >
2015-06-13 19:46:07 +02:00
< / div >
2016-04-20 20:47:23 +02:00
< div class = "form-row" >
< label for = "node-input-protocol" > < i class = "fa fa-envelope" > < / i > < span data-i18n = "email.label.protocol" > < / span > < / label >
< select type = "text" id = "node-input-protocol" >
< option value = "IMAP" > IMAP< / option >
< option value = "POP3" > POP3< / option >
< / select >
< / div >
< div class = "form-row" >
2016-08-03 09:55:39 +02:00
< label for = "node-input-useSSL" > < i class = "fa fa-lock" > < / i > < span data-i18n = "email.label.useSSL" > < / span > < / label >
< input type = "checkbox" id = "node-input-useSSL" style = "width: auto;" >
2016-04-20 20:47:23 +02:00
< / div >
2015-06-13 19:46:07 +02:00
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-server" > < i class = "fa fa-globe" > < / i > < span data-i18n = "email.label.server" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "text" id = "node-input-server" placeholder = "imap.gmail.com" >
< / div >
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-port" > < i class = "fa fa-random" > < / i > < span data-i18n = "email.label.port" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "text" id = "node-input-port" placeholder = "993" >
< / div >
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-userid" > < i class = "fa fa-user" > < / i > < span data-i18n = "email.label.userid" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "text" id = "node-input-userid" >
< / div >
< div class = "form-row" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-password" > < i class = "fa fa-lock" > < / i > < span data-i18n = "email.label.password" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "password" id = "node-input-password" >
< / div >
2016-04-20 20:47:23 +02:00
< div class = "form-row node-input-box" >
2015-06-16 11:36:19 +02:00
< label for = "node-input-box" > < i class = "fa fa-inbox" > < / i > < span data-i18n = "email.label.folder" > < / span > < / label >
2015-06-13 19:46:07 +02:00
< input type = "text" id = "node-input-box" >
< / div >
2016-04-20 20:47:23 +02:00
< div class = "form-row node-input-disposition" >
2016-08-03 09:55:39 +02:00
< label for = "node-input-disposition" > < i class = "fa fa-trash" > < / i > < span data-i18n = "email.label.disposition" > < / span > < / label >
2016-04-20 20:47:23 +02:00
< select type = "text" id = "node-input-disposition" >
< option value = "None" selected = "selected" > None< / option >
< option value = "Read" > Mark Read/Answered< / option >
< option value = "Delete" > Delete< / option >
< / select >
< / div >
2015-06-13 19:46:07 +02:00
< br / >
< div class = "form-row" >
2015-06-16 12:16:29 +02:00
< label for = "node-input-name" > < i class = "fa fa-tag" > < / i > < span data-i18n = "node-red:common.label.name" > < / span > < / label >
< input type = "text" id = "node-input-name" data-i18n = "[placeholder]node-red:common.label.name" >
2015-06-13 19:46:07 +02:00
< / div >
2016-04-20 20:47:23 +02:00
< script >
var checkPorts = function() {
var currentPort = $("#node-input-port").val();
if (currentPort === "143" || currentPort === "993" || currentPort === "110" || currentPort == "995") {
if ($("#node-input-useSSL").prop("checked") === true) {
$("#node-input-port").val($("#node-input-protocol").val() === "IMAP"?"993":"995");
} else {
$("#node-input-port").val($("#node-input-protocol").val() === "IMAP"?"143":"110");
}
}
};
2016-05-19 11:13:47 +02:00
2016-04-20 20:47:23 +02:00
$("#node-input-useSSL").change(function(x, y) {
console.log("useSSL: x="+ JSON.stringify(x) + ", y=" + y);
console.log("Value: " + $("#node-input-useSSL").prop("checked"));
checkPorts();
});
2016-05-19 11:13:47 +02:00
2016-04-20 20:47:23 +02:00
$("#node-input-protocol").change(function() {
var protocol = $("#node-input-protocol").val();
if (protocol === "IMAP") {
$(".node-input-box").show();
$(".node-input-disposition").show();
} else {
$(".node-input-box").hide();
2016-05-19 11:13:47 +02:00
$(".node-input-disposition").hide();
2016-04-20 20:47:23 +02:00
}
checkPorts();
});
< / script >
2015-06-13 19:46:07 +02:00
< / script >
< script type = "text/x-red" data-help-name = "e-mail in" >
< p > Repeatedly gets a < b > single email< / b > from an IMAP server and forwards on as a msg if not already seen.< / p >
2016-02-12 15:05:10 +01:00
< p > The subject is loaded into < code > msg.topic< / code > and < code > msg.payload< / code > is the plain text body.
If there is text/html then that is returned in < code > msg.html< / code > . < code > msg.from< / code > and < code > msg.date< / code > are also set if you need them.< / p >
< p > Additionally < code > msg.header< / code > contains the complete header object including
2015-06-13 19:46:07 +02:00
< i > to< / i > , < i > cc< / i > and other potentially useful properties.< / p >
< p > Uses the imap module.< / p >
< p > < b > Note:< / b > this node < i > only< / i > gets the most recent single email from the inbox, so set the repeat (polling) time appropriately.< / p >
2016-02-26 22:59:43 +01:00
< p > Note: uses IMAP with SSL to port 993.< / p >
2016-04-20 20:47:23 +02:00
< p > Any attachments supplied in the incoming email can be found in the < code > msg.attachments< / code > property. This will be an array of objects where
each object represents a specific attachments. The format of the object is:< / p >
2016-05-19 11:13:47 +02:00
2016-04-20 20:47:23 +02:00
< pre >
{
contentType: // The MIME content description
fileName: // A suggested file name associated with this attachment
transferEncoding: // How was the original email attachment encodded?
contentDisposition: // Unknown
generatedFileName: // A suggested file name associated with this attachment
contentId: // A unique generated ID for this attachment
checksum: // A checksum against the data
length: // Size of data in bytes
content: // The actual content of the data contained in a Node.js Buffer object
// We can turn this into a base64 data string with content.toString('base64')
}
< / pre >
< p > For POP3, the default port numbers are 110 for plain TCP and 995 for SSL. For IMAP the port numbers are 143 for plain TCP and 993 for SSL.< / p >
2015-06-13 19:46:07 +02:00
< / script >
< script type = "text/javascript" >
(function() {
RED.nodes.registerType('e-mail in',{
category: 'social-input',
color:"#c7e9c0",
defaults: {
name: {value:""},
2016-04-20 20:47:23 +02:00
protocol: {value: "IMAP", required:true}, // Which protocol to use to connect to the mail server ("IMAP" or "POP3")
2015-06-13 19:46:07 +02:00
server: {value:"imap.gmail.com",required:true},
2016-04-20 20:47:23 +02:00
useSSL: {value: true},
2015-06-13 19:46:07 +02:00
port: {value:"993",required:true},
2016-05-19 11:13:47 +02:00
box: {value:"INBOX"}, // For IMAP, The mailbox to process
2016-04-20 20:47:23 +02:00
disposition: { value: "None" }, // For IMAP, the disposition of the read email
2015-06-13 19:46:07 +02:00
repeat: {value:"300",required:true}
},
credentials: {
userid: {type:"text"},
password: {type: "password"},
global: { type:"boolean"}
},
inputs:0,
outputs:1,
icon: "envelope.png",
label: function() {
return this.name||"email";
},
labelStyle: function() {
return (this.name||!this.topic)?"node_label_italic":"";
},
oneditprepare: function() {
if (this.credentials.global) {
$('#node-tip').show();
} else {
$('#node-tip').hide();
2015-06-16 15:38:36 +02:00
}
2015-06-13 19:46:07 +02:00
if (typeof this.box === 'undefined') {
$("#node-input-box").val("INBOX");
this.box = "INBOX";
}
}
});
})();
< / script >