Reputation: 913
I have a plan to implement mailer application in Java. Therefore, I have a question about checking the existence of new mails.
For example, in Thunderbird, Polling interval option exists in server preference. (default interval is 10 minutes.) But, thunderbird looks like that it notifies immediately when a new mail comes. This behaviour is same however default interval changes.
What does this interval mean? And, how do I implement that the application notifies immediately when a new mail comes. (Should I implement that an application has polling check funciton whether new mail comes or not?)
Upvotes: 2
Views: 1698
Reputation: 5211
By default when using IMAP a client will connect, see if there are any new messages, if there are process them and disconnect and if not just disconnect. The client will then try again after an interval of say 10 minutes. However, there is a command in IMAP called IDLE. This basically states that you wish to keep the connection open and be notified whenever a new message occurs. The command is defined in RFC2177.
The command is fairly simple (from RFC2177):
C: A002 IDLE
S: + idling
...time passes; new mail arrives...
S: * 4 EXISTS
C: DONE
I'm not sure whether any of the java clients support this but if not it would be quite trivial to implement. You'd also need to add something to check that the server supports the IDLE command (using capabilities) and also to reconnect should a failure occur.
It's also worth noting that there are systems such as http://cloudmailin.com that allow you to receive your email as an http post. This gives you the benefit of having a 'live' response time without having to poll for the email at all.
Upvotes: 1