mscdex / node-imap

An IMAP client module for node.js.
MIT License
2.17k stars 382 forks source link

Issue on event "mail" with outlook only #915

Open anasmebarki1996 opened 8 months ago

anasmebarki1996 commented 8 months ago

Issue Description I am using the imap library to receive emails in my Node.js application. I have set up event handling for the 'mail' event to log a message whenever a new email is received:

imap.on('mail', async (numNewMsgs) => {
  console.log(`New email received: ${numNewMsgs}`);
});

However, I am encountering an issue where the application behaves differently when connected to Outlook's IMAP server compared to Gmail's IMAP server.

Problem

Configuration Here is the configuration I am using for the IMAP connection:

this.imap = new Imap({
  user: process.env.OUTLOOK_ACCOUNT_EMAIL,
  password: process.env.OUTLOOK_ACCOUNT_PASSWORD,
  host: process.env.OUTLOOK_ACCOUNT_HOST,
  port: 993,
  tls: true,
  keepalive: {
    interval: 10000,
    idleInterval: 0,
    forceNoop: true,
  },
  tlsOptions: {
    rejectUnauthorized: false,
  },
});

Suggestions Needed I would appreciate any suggestions or insights on why the application behaves differently with Outlook's IMAP server and how I can ensure consistent behavior across different email providers.

Thank you in advance for your help!