Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail events are not triggered most of the time #889

Open
LanXiaoChr opened this issue Sep 19, 2022 · 1 comment
Open

Mail events are not triggered most of the time #889

LanXiaoChr opened this issue Sep 19, 2022 · 1 comment

Comments

@LanXiaoChr
Copy link

LanXiaoChr commented Sep 19, 2022

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: '[email protected]',
    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 "[email protected]" "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'
@vininjr
Copy link

vininjr commented Dec 16, 2022

`
let imap = new Imap({

user: '[email protected]',
password: 'xxxxxxxx',
host: 'imap.xxxx.com',
port: 993,
tls: true,
keepalive: {
  interval: 10000,
  idleInterval: 0,
  forceNoop: true,
},

})
`
/** This is the interval (in milliseconds) at which NOOPs are sent and the interval at which idleInterval is checked. Default: 10000 /
interval?: number | undefined;
/
* This is the interval (in milliseconds) at which an IDLE command (for servers that support IDLE) is re-sent. Default: 300000 (5 mins) /
idleInterval?: number | undefined;
/
* Set to true to force use of NOOP keepalive on servers also support IDLE. Default: false */
forceNoop?: boolean | undefined;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants