简体   繁体   English

如何使用Java从Gmail帐户自动获取新邮件?

[英]How to automatically get new mails from gmail account using java?

I know my question is more likely to be discussed rather than really answered (because it's very large), but I need some elements and "advices" to really get started, sorry for that. 我知道我的问题更有可能讨论而不是真正回答(因为问题很大),但是我需要一些要素和“建议”才能真正开始,对此感到抱歉。

So I've got a java program which has to analyse some URLs, I've finished this part. 因此,我有一个必须分析一些URL的Java程序,我已经完成了这一部分。 For the moment, the user has to enter manually the link into my program, then the link is analysed. 目前,用户必须将链接手动输入到我的程序中,然后分析链接。

Now I have to retrieve automatically those links, which will be sent to me via e-mail. 现在,我必须自动检索那些链接,这些链接将通过电子邮件发送给我。 (In a special Gmail inbox created for that purpose) (在为此目的创建的特殊Gmail收件箱中)

So I need to : 所以我需要:

  • Let my Java program "listen" to my inbox 让我的Java程序“收听”我的收件箱
  • Extract the link of any new mail in order to analyse it 提取任何新邮件的链接以便对其进行分析

There are many problems, according to the way I choose to access to my inbox (POP3, GMail API...), according to the frequency my application would check the inbox, maybe there would be authentification problems... Even how to let my application run as a "daemon"... 根据我选择访问我的收件箱的方式(POP3,GMail API ...),有很多问题,根据我的应用程序检查收件箱的频率,也许会有身份验证问题...甚至如何我的应用程序作为“守护程序”运行...

And I really don't know how to get started, which choices to make etc. 而且我真的不知道如何开始,做出哪些选择等。

Any help is welcome of course, if you have any documentation or else. 如果有任何文档,当然可以提供任何帮助。 Thank you in advance. 先感谢您。

You have several ways of doing this. 您有几种方法可以做到这一点。

I suggest you using Java Mail, that has a simple and useful API. 我建议您使用Java Mail,它具有简单实用的API。

You have some documentation and examples in this URL: 您在此URL中有一些文档和示例:

https://java.net/projects/javamail/pages/Home#Samples https://java.net/projects/javamail/pages/Home#Samples

Look at the class monitor (very bad name!!!) inside the examples. 查看示例中的类monitor (非常糟糕的名称!!!)。 This class monitor a mail box for new emails. 此类监视邮箱中是否有新电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM