From the Javamail FAQ ( http://www.oracle.com/technetwork/java/javamail/faq/index.html ):
Q : I configured MessageCountListener
(as shown in the monitor program), but I never notify of new mail in my POP3 INBOX.
A. The POP3 protocol prevents the client from seeing new messages delivered to INBOX while INBOX is open. The application should close INBOX and reopen it to see new messages. You will never be notified of new mail using the MessageCountListener
interface with POP3. See the com.sun.mail.pop3
package documentation for more details.
So MessageCountListener
will not work for POP3. You will need to complete a survey to receive information about new messages for POP3.
However, you can try using IMAP.
But even with IMAP, you have to use it differently. See the idle()
method in the IMAPStore
class (for example, it is called in a loop in a separate thread, etc. - see https://javamail.java.net/nonav/docs/api/com/sun/mail/imap/ IMAPStore.html # idle () ).
denis source share