This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes General Computing and the fly likes General question how does email client knows about incoming mail? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "General question how does email client knows about incoming mail?" Watch "General question how does email client knows about incoming mail?" New topic
Author

General question how does email client knows about incoming mail?

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hello all ( im not sure this is the right form ,sorry)
i need to write simple client that connects to the email server and will know when serten email
massage is arriving ,
my question is how does the ordinary email clients works and know that
email are arriving ?
i have the code and every thing but i miss the way to how to implement this part .
i dont know if the idea of connection every N seconds to the email server will be the right idea.
does they check every N seconds the server or they have some of other method to do this?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Meir Yan:
i dont know if the idea of connection every N seconds to the email server will be the right idea.
does they check every N seconds the server or they have some of other method to do this?


That's exactly how they do it (it's called "pulling") - although it's probably a better idea to do it every couple of minutes instead of seconds. Most email clients allow you to configure the interval.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Yes, please default to a few minutes, maybe 10 or 15, rather than seconds.
For users with broadband, always on connections, it doesn't really matter, but its a waste of server cycles, people just don't get mail that frequently.

On networks that are not constantly on, and especially those that charge per connection, you want be frugal with the connections. Back in the mid 1990s, on ISDN, the telco charged a nickel (5 cents) for every start of the connection. One salesman was unaware, and set his mail check to every minute and ran up hundreds of dollars worth of billing.

In more modern times, the connection is likely to be cell phone or other network, and they too have strange charging algorithms.
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hi and thanks for the fast reply
Well in my scenario (which I don�t sure what is the best way to implement it).
My pop3 client need to know when incoming mail with define subject is arriving and perform action
So I guess in my case the client needs to sample the email server every N seconds.
I'm using home idsl connation.
But you mention somkind of connection pool limit, so I guess I need to keep persistent connection to the email server
And query every N seconds about incoming mails
Is this the right way ?
 
wood burning stoves
 
subject: General question how does email client knows about incoming mail?