本文介绍了JavaMail是否支持服务器推送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! JavaMail是否支持通过服务器推送通知新的电子邮件?Does JavaMail support notification of new emails through server-push?如果是,该文档在哪里? 如果没有,有没有可以做的图书馆?If yes, where is the documentation for that?If no, is there a library that can do it?推荐答案你应该使用IMAPFolder的 idle 函数向服务器发出空闲命令。然后,它将收听诸如新邮件或已删除邮件等事件。 (请参阅IMAP规范以查看消息的样子)。而邮箱中的一些电子邮件更改时,您应该使用 MessageCountListener 来执行代码。You should be using IMAPFolder's idle function to issue the idle command to the server. That will then listen for events, such as a new mail or deleted mail. (See the IMAP spec to see what the messages look like). And you should be using a MessageCountListener to execute code when a number of emails in the mailbox change. IMAP的空闲功能正是为了模仿推功能。IMAP's idle function is exactly meant to imitate "push" functionality. http://java.sun.com/products/javamail/javadocs/javax/mail/event/MessageCountListener.html http://java.sun.com/products/ javamail / javadocs / com / sun / mail / imap / IMAPFolder.html对不起,我没有发布任何显示如何使用的代码。我不想浪费我的时间,因为在互联网上有很多很容易获得的例子,如果你搜索这个东西。Sorry I didn't post any code that shows how this is used. I didn't want to waste my time since there are many readily available examples on the internet if you search for this stuff.但要预先警告,这种方法不会自从空闲命令阻止以来,可以为多个IMAP帐户工作。除非你想要他们所有在不同的线程(坏主意)。But be forewarned, this method won't work for more than one IMAP account since the idle command blocks. Unless you want them all on different threads (bad idea). 这篇关于JavaMail是否支持服务器推送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 04:22