Closed lucfranken closed 1 year ago
ImapFlow does not work with Node.js 14. Whenever you hit a method that is not supported by Node 14 (e.g. String.at()), you will get an error. If you are unable to upgrade Node, you could install EmailEngine and use it as an API backend instead of connecting to IMAP servers directly with ImapFlow.
For records, adding this monkey patch code (generated by chatgpt) overcome the issue:
// Polyfill for String.prototype.at() method
if (!String.prototype.at) {
String.prototype.at = function(index) {
// Convert index to a number, in case a string is passed
index = Number(index);
// If index is negative, calculate the position from the end of the string
if (index < 0) index = this.length + index;
// Return the character at the specified index, or undefined if index is out of bounds
return index >= 0 && index < this.length ? this.charAt(index) : undefined;
};
}
Describe the bug
At first try with the library I run into this one:
Exception is raised when activating envelope: true.
To Reproduce
I use the following code below.
When I set: envelope = false no error happens. With envelope = true error happens.
When envelope = false I do receive e-mail id's etc. So the code generally works.
Relevant code in imapflow:
https://github.com/postalsys/imapflow/blob/d48d0d84e169d0c4315e32d1d565c08f382cace7/lib/tools.js#L358
Expected behavior
No error.
Code example
Platform
OSX Node v14.21.3 (Meteor)