GithubHelp home page GithubHelp logo

Comments (12)

mscdex avatar mscdex commented on September 18, 2024 2

@gkrcode set the markSeen property of fetch()'s second argument to false (e.g. fetch(12345, { markSeen: false, ... }); )

markSeen defaults to false anyway though....

from node-imap.

andris9 avatar andris9 commented on September 18, 2024

The answer for 2) is that you should set the readOnly parameter for openBox to true

imap.openBox('INBOX', true, cb);

from node-imap.

gkrcode avatar gkrcode commented on September 18, 2024

Thanks andris,

But it stops me from making changes to the opened box, Is there any other way to stop the auto 'Mark as Read' ?

from node-imap.

gkrcode avatar gkrcode commented on September 18, 2024

Thanks @mscdex, still looking for answer for the question no 1 too :)

from node-imap.

mscdex avatar mscdex commented on September 18, 2024

@gkrcode I don't quite understand your first question. The mail event should only fire when new mail comes in while you're connected.

So if the mail event is emitted one time for 5 new emails and then a short time later is emitted for 10 new emails, those previous 5 are not included in the 10 that just arrived. Assuming you had no other unseen emails during this time, a search() then for unseen emails would result in a total of 15 new messages.

from node-imap.

gkrcode avatar gkrcode commented on September 18, 2024

thanks @mscdex

Please let me explain it more clearly,

As for as I know about IMAP we cant send new commands while in IDLE state. I guess node-imap get out of IDLE state before emitting 'mail' event so how it will know about new mails the openedBox received before it getting back into IDLE state again or It just miss those mails ?

from node-imap.

mscdex avatar mscdex commented on September 18, 2024

Correct, you cannot issue commands while in IDLE, but the module takes care of all of that for you so you don't have to worry about it. However, because of the way IDLE works, the module does not have to exit or re-establish IDLE mode when emitting the 'mail' event.

The IDLE IMAP extension lets the server tell you when changes to the currently open mailbox have occurred (new emails, deletions, etc). When the server does notify the client, the server sends the client the total number of deleted and/or new emails. However, the module internally keeps track of all of these counts and always calculates the difference so that you know how many new emails came in since the last notification or since opening the mailbox for example.

There is another IMAP extension that is starting to become adopted among the more widely used IMAP servers, and that is the NOTIFY extension (rfc 5465). This is a much more flexible mechanism that can monitor multiple boxes simultaneously with the ability to use filters for such notifications (e.g. only flag changes, mailbox creation/deletion/renaming events, new messages, message deletions, etc). Support for this extension is already on my todo list, but I need to think about the best way to implement this since there is no way to emulate this extension for servers that do not support it yet.

from node-imap.

gkrcode avatar gkrcode commented on September 18, 2024

Thanks @mscdex

"but the module takes care of all of that for you so you don't have to worry about it. However, because of the way IDLE works, the module does not have to exit or re-establish IDLE mode when emitting the 'mail' event."

If possible can you explain little more on how it does that magic :)

"the module internally keeps track of all of these counts and always calculates the difference so that you know how many new emails came in since the last notification or since opening the mailbox for example."

Now I understood node-imap wont miss mails.

"is the NOTIFY extension (rfc 5465)"

Great extension looking forward.

from node-imap.

andris9 avatar andris9 commented on September 18, 2024

@mscdex do you know any IMAP server implementations that support NOTIFY? I checked the capabilities for Gmail IMAP server, a Dovecot and a Cyrus installation but none of them supported it.

Currenlty the "industry standard" seems to be STATUS polling + opening several connections to achieve the same result as with NOTIFY.

from node-imap.

mscdex avatar mscdex commented on September 18, 2024

@gkrcode Well, basically if there are no commands queued up (to be sent to the server), IDLE mode is entered automatically (if the server supports it of course). When you call a function like fetch() or anything else that needs to contact the server, IDLE mode is exited first, then the command(s) are sent, then repeat (go back to IDLE mode).

@andris9 The ones I know of that support it so far (as of this writing) are: Dovecot (at least some support exists in the dev repo, full implementation slated for 2.2?) and Archiveopteryx. Most other servers currently only have other methods for doing push mail, such as custom out-of-band protocols and/or ActiveSync, etc.

from node-imap.

gkrcode avatar gkrcode commented on September 18, 2024

@mscdex, thank you very much :)

from node-imap.

azharuniverse avatar azharuniverse commented on September 18, 2024

Tried all solutions. Nothing working. marking all my incoming emails as read automatically.

from node-imap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.