mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Expose rest of email node header fields.
This commit is contained in:
parent
269846c587
commit
73d1f3d0e8
@ -155,7 +155,8 @@
|
|||||||
<p>Repeatedly gets a <b>single email</b> from an IMAP server and forwards on as a msg if not already seen.</p>
|
<p>Repeatedly gets a <b>single email</b> from an IMAP server and forwards on as a msg if not already seen.</p>
|
||||||
<p>The subject is loaded into <b>msg.topic</b> and <b>msg.payload</b> is the plain text body.
|
<p>The subject is loaded into <b>msg.topic</b> and <b>msg.payload</b> is the plain text body.
|
||||||
If there is text/html then that is returned in <b>msg.html</b>. <b>msg.from</b> and <b>msg.date</b> are also set if you need them.</p>
|
If there is text/html then that is returned in <b>msg.html</b>. <b>msg.from</b> and <b>msg.date</b> are also set if you need them.</p>
|
||||||
<p>Additionally <b>msg.to</b>, <b>msg.cc</b>, <b>msg.bcc</b> may exist and contain arrays of relevant email addresses.</p>
|
<p>Additionally <b>msg.header</b> contains the complete header object including
|
||||||
|
<i>to</i>, <i>cc</i> and other potentially useful properties.</p>
|
||||||
<p>Uses the imap module.</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>
|
<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>
|
||||||
</script>
|
</script>
|
||||||
|
@ -181,7 +181,8 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (box.messages.total > 0) {
|
if (box.messages.total > 0) {
|
||||||
var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER.FIELDS (FROM SUBJECT DATE TO CC BCC)','TEXT'] });
|
//var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER.FIELDS (FROM SUBJECT DATE TO CC BCC)','TEXT'] });
|
||||||
|
var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER','TEXT'] });
|
||||||
f.on('message', function(msg, seqno) {
|
f.on('message', function(msg, seqno) {
|
||||||
node.log('message: #'+ seqno);
|
node.log('message: #'+ seqno);
|
||||||
var prefix = '(#' + seqno + ') ';
|
var prefix = '(#' + seqno + ') ';
|
||||||
@ -193,13 +194,10 @@ module.exports = function(RED) {
|
|||||||
stream.on('end', function() {
|
stream.on('end', function() {
|
||||||
if (info.which !== 'TEXT') {
|
if (info.which !== 'TEXT') {
|
||||||
var head = Imap.parseHeader(buffer);
|
var head = Imap.parseHeader(buffer);
|
||||||
if (RED.settings.verbose) { node.log(head); }
|
|
||||||
pay.from = head.from[0];
|
pay.from = head.from[0];
|
||||||
pay.topic = head.subject[0];
|
pay.topic = head.subject[0];
|
||||||
pay.date = head.date[0];
|
pay.date = head.date[0];
|
||||||
if (head.hasOwnProperty("to")) { pay.to = head.to; }
|
pay.header = head;
|
||||||
if (head.hasOwnProperty("cc")) { pay.cc = head.cc; }
|
|
||||||
if (head.hasOwnProperty("bcc")) { pay.bcc = head.bcc; }
|
|
||||||
} else {
|
} else {
|
||||||
var parts = buffer.split("Content-Type");
|
var parts = buffer.split("Content-Type");
|
||||||
for (var p = 0; p < parts.length; p++) {
|
for (var p = 0; p < parts.length; p++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user