forked from mscdex/node-imap
-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
When I create a simple node project and basically run with just ts-node runfile.ts
I get this error:
/Users/peterkellner/repos/gmail-to-icloud/process-mail-queue/node_modules/imap/lib/Connection.js:227
var type = self._curReq.type;
^
TypeError: Cannot read properties of undefined (reading 'type')
My example is just this which is exactly what is on the home page:
import Imap from "imap";
import {inspect} from "node:util";
const imap = new Imap({
user: "xxx",
password: "xxx",
host: "imap.gmail.com",
port: 993,
tls: true,
tlsOptions: {rejectUnauthorized: false},
});
function openInbox(cb) {
imap.openBox("INBOX", true, cb);
}
imap.once("ready", function () {
openInbox(function (err) {
if (err) throw err;
const f = imap.seq.fetch("1:3", {
bodies: "HEADER.FIELDS (FROM TO SUBJECT DATE)",
struct: true,
});
f.on("message", function (msg, seqno) {
console.log("Message #%d", seqno);
const prefix = "(#" + seqno + ") ";
msg.on("body", function (stream) {
let buffer = "";
stream.on("data", function (chunk) {
buffer += chunk.toString("utf8");
});
stream.once("end", function () {
console.log(prefix + "Parsed header: %s", inspect(Imap.parseHeader(buffer)));
});
});
msg.once("attributes", function (attrs) {
console.log(prefix + "Attributes: %s", inspect(attrs, false, 8));
});
msg.once("end", function () {
console.log(prefix + "Finished");
});
});
f.once("error", function (err) {
console.log("Fetch error: " + err);
});
f.once("end", function () {
console.log("Done fetching all messages!");
imap.end();
});
});
});
imap.once("error", function (err) {
console.log(err);
});
imap.once("end", function () {
console.log("Connection ended");
});
imap.connect();
Metadata
Metadata
Assignees
Labels
No labels