node-imap icon indicating copy to clipboard operation
node-imap copied to clipboard

Mail event

Open qxxxoDev opened this issue 4 years ago • 2 comments

imap.on('mail') How to make this trigger email receiving event all the time, because my IMAP connection lasts forever, but om mail event not.

qxxxoDev avatar Aug 25 '21 18:08 qxxxoDev

It's only triggered when there's new mail in the mailbox that you currently have open.

mscdex avatar Aug 25 '21 19:08 mscdex

@mscdex What happens if the email arrives before imap.on() starts listening - In my observation, imap.on() ignores the email.

I'm running the email code in my test suite to retrieve verification codes and sometimes messages arrives faster than expected. In this case imap.on() still listens for new incoming email and doesn't let to move on for imap.search()

imap.once('ready', function () { openInbox(function (err, box) { if (err) throw err imap.on('mail', function (newMsgNum: number) {}

Thanks!

enesecer avatar Oct 19 '22 16:10 enesecer