Skip to content
Neil Kolban edited this page Mar 7, 2016 · 18 revisions

The Email node provides both input and output of emails. The node is available on NPM at:

As of 2016-03-06, the node has dependencies on:


Reading emails

The current implementation uses the IMAP protocol to interact with a back-end IMAP provider. The very last email seen is received and the message added to an emitted event. If the email body is plain text, it is added to msg.payload. If the email body is HTML, it is added to msg.html. The subject line of the email is propagated in msg.topic.


Future enhancements

There are a number of potential enhancements available to the email node that can be addressed. These include:

  • Support of IMAP that is not over SSL/TLS.
  • Support for self-certified SSL certificates.
  • Support for attachment processing. Attachments should appear as an array in msg.attachments.
  • Support for POP3 as well as IMAP.
  • Support for more than just last message processing.

Design Notes

Parsing incoming emails

Consider an email message that is sitting on an email server. It appears that an email is transmitted over SMTP and received by the email server and stored. It also appears that the email is saved in a certain format. That email can then be retrieved by a client application using IMAP and/or POP3.

Question: Is the email message retrieved via IMAP and POP3 the same format/content? If I retrieve the "blob-o-data" that represents my email, do I get the same think with both IMAP and POP3 retrievers?

Question: For POP3 clients, is it acceptable to delete/destroy a message once received and processed?

Question: For attachments, how should the attachment be stored in the attachments array?


Related forum posts and issues:


Related NPM packages


Technical tasks

  • How do we retrieve an email using POP3?

Examining the documentation for poplib, the high level is:

var client = new POP3Client(...);
// Called when the client had connected to the POP3 server ...
client.on("connect", function() {
  client.login(...); // Login to the server
});

// Called when we have logged in ...
client.on("login", function(..., rawdata) {
  client.list(); // List the messages
});

// Called with a list response ...
client.on("list", function(...) {
  client.retr(...); // Retrieve a message
});

// Called when a message has been retrieved ...
client.on("retr", function(...) {
  client.dele(...); // Delete a message
});

// Called when a message has been deleted ...
client.on("dele", function(...) {
});
  • What does the response from a POP3 'list' request look like?

The event for list contains status, msgCount, msgNumber and data. Of these, examination seems to show that the important one is msgCount. This is the number of messages in the mailbox. If 0, then there are no messages.

  • What does the response from a POP3 retr request look like?

The event for retr contains status, msgNumber and data. The data is the body of the email ... this is truly the whole body and includes headers and payload.

Clone this wiki locally