You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I have a job process that downloads email using node-imap.
I have a kaspersky antivirus which scans email in mailbox in search of malware. While the antivirus does this scan, if node-imap fetch the email body, it returns with empty body.
Is there some work around to deal with it?
This is my script:
function main() {
const Imap = require("imap");
const inspect = require("util").inspect;
const imap = new Imap({
user: "[email protected]",
password: "your-password",
host: "imap.example.com",
port: 993,
tls: true,
});
imap.once("ready", function () {
imap.openBox("INBOX", true, function (err, box) {
if (err) throw err;
let fetched = 0;
let total = box.messages.total;
let fetch = imap.fetch(box.messages.total + ":*", {
bodies: "HEADER.FIELDS (FROM TO SUBJECT DATE)",
});
fetch.on("message", function (msg, seqno) {
console.log("Message #%d", seqno);
let prefix = "(#" + seqno + ") ";
msg.on("body", function (stream, info) {
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))
);
fetched++;
if (fetched === total) {
imap.end();
}
});
});
msg.once("attributes", function (attrs) {
console.log(prefix + "Attributes: %s", inspect(attrs, false, 8));
});
msg.once("end", function () {
console.log(prefix + "Finished");
});
});
fetch.once("error", function (err) {
console.log("Fetch error: " + err);
});
fetch.once("end", function () {
console.log("Done fetching all messages!");
});
});
});
imap.once("error", function (err) {
console.log(err);
});
imap.once("end", function () {
console.log("Connection ended");
});
imap.connect();
}
The text was updated successfully, but these errors were encountered:
Worked around the issue with SEARCH criteria HEADER
Example imap.search(['UNSEEN','HEADER','ANTI-SPAM'], handleEmails())
Emails without the header are yet to be scanned so this prevent fetching them.
Hello I have a job process that downloads email using node-imap.
I have a kaspersky antivirus which scans email in mailbox in search of malware. While the antivirus does this scan, if node-imap fetch the email body, it returns with empty body.
Is there some work around to deal with it?
This is my script:
The text was updated successfully, but these errors were encountered: