Closed ghost closed 4 years ago
Do you see updates when you set keepalive: { forceNoop: true }
in your connection config object?
No, no change, did it like this:
const imap = new Imap({
user: 'xxx@gmail.com',
password: 'xxx',
host: 'imap.gmail.com',
port: 993,
tls: true,
tlsOptions: { servername: 'imap.gmail.com' },
keepalive: { forceNoop: true }
});
Oh I see the issue now, you're using imap.once()
instead of imap.on()
. Change that and you should see the new mail notifications.
Ah, I see, once like “one time” not like “once it happens” :) Sorry no native english speaker.
Yes, now the new mail event is triggered, also when i move something out of inbox the expunge event gets triggered.
but when i move something from one subscribed folder to another nothing happens. how do I keep track of whats happening in the other boxes? What do i subscribe for?
subscribeBox()
doesn't do what you're thinking it does. If you want to monitor other mailboxes (efficiently), you will need separate connections.
I see, subscribe is only to mark mailboxes, it does not have any technical consequence. Those old protocols are kinda weird. Thanks for your help!
Actually subscribeBox()
is a bit of a relic back when the creators of IMAP envisioned some sort of Usenet-like "mailbox" subscription experience.
I connect to gmail and can open Inbox. It works to fetch emails. But the mail event gets only fired once at start, when i fetch mails, it does not get fired when i send a new mail.
also subscribing does not seem to have any effect. I have all connection events logging their args to console, but they never get fired. My understanding would have been, that not ending imap would keep the connection open and new mail to a subscribed box would trigger mail or update or any other event. But nothing happens. What am I getting wrong?
This is my whole testcode: