When I receive a new email in my work email, the ‘mail’ event doesn't fire. It's the same when I use my private email.
Sometimes, when I rerun the program it may work but most of the time it doesn't.
const Imap = require('imap')
let imap = new Imap({
user: 'xxxxxx@xxx.com',
password: 'xxxxxxxx',
host: 'imap.xxxx.com',
port: 993,
tls: true
})
imap.once('ready', () => {
imap.openBox('INBOX', true, (err, box) => {
if (err) throw err
})
})
imap.on('mail', (mail) => {
console.log('new email: ' + mail)
})
imap.connect()
Log:
$ node test.js
[connection] Connected to host
<= '* OK [CAPABILITY IMAP4 IMAP4rev1 ID AUTH=PLAIN AUTH=LOGIN AUTH=XOAUTH2 NAMESPACE] QQMail XMIMAP4Server ready'
=> 'A0 CAPABILITY'
<= '* CAPABILITY IMAP4 IMAP4rev1 XLIST MOVE IDLE XAPPLEPUSHSERVICE AUTH=PLAIN AUTH=LOGIN AUTH=XOAUTH2 NAMESPACE CHILDREN ID UIDPLUS'
<= 'A0 OK CAPABILITY Completed'
=> 'A1 LOGIN "xxxxxx@xxx.com" "xxxxxxxx"'
<= 'A1 OK Success login ok'
=> 'A2 CAPABILITY'
<= '* CAPABILITY IMAP4 IMAP4rev1 XLIST MOVE IDLE XAPPLEPUSHSERVICE NAMESPACE CHILDREN ID UIDPLUS'
<= 'A2 OK CAPABILITY Completed'
=> 'A3 NAMESPACE'
<= '* NAMESPACE (("" "/")) NIL NIL'
<= 'A3 OK NAMESPACE Success'
=> 'A4 LIST "" ""'
<= '* LIST (\\NoSelect) "/" "/"'
<= 'A4 OK LIST completed'
=> 'A5 EXAMINE "INBOX"'
<= '* 69 EXISTS'
new email: 69
<= '* 0 RECENT'
<= '* OK [UNSEEN 8]'
<= '* OK [UIDVALIDITY 1663402387] UID validity status'
<= '* OK [UIDNEXT 2664] Predicted next UID'
<= '* FLAGS (\\Answered \\Flagged \\Deleted \\Draft \\Seen)'
<= '* OK [PERMANENTFLAGS ()] No permanent flags permitted'
<= 'A5 OK [READ-ONLY] EXAMINE complete'
=> 'IDLE IDLE'
<= '+ idling'
When I receive a new email in my work email, the ‘mail’ event doesn't fire. It's the same when I use my private email.
Sometimes, when I rerun the program it may work but most of the time it doesn't.
Log: