Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用java Mail从POP3获取消息Id_Java_Email_Jakarta Mail_Pop3 - Fatal编程技术网

如何使用java Mail从POP3获取消息Id

如何使用java Mail从POP3获取消息Id,java,email,jakarta-mail,pop3,Java,Email,Jakarta Mail,Pop3,从url , 您还可以预取所有消息的所有UID,如下所示: FetchProfile fp = new FetchProfile(); fp.add(UIDFolder.FetchProfileItem.UID); folder.fetch(folder.getMessages(), fp); 然后使用上述技术获取每条消息的UID。这与IMAP支持的UIDFolder接口使用的技术类似,但请注意,POP3 UID是字符串,而不是像IMAP UID那样的整数。有关详细信息,请参见POP3规范 由

从url

,

您还可以预取所有消息的所有UID,如下所示:

FetchProfile fp = new FetchProfile();
fp.add(UIDFolder.FetchProfileItem.UID);
folder.fetch(folder.getMessages(), fp);
然后使用上述技术获取每条消息的UID。这与IMAP支持的UIDFolder接口使用的技术类似,但请注意,POP3 UID是字符串,而不是像IMAP UID那样的整数。有关详细信息,请参见POP3规范

由此,
https://www.ietf.org/rfc/rfc1939.txt,

在第七章中,有一个我需要的例子

示例:

         S: +OK POP3 server ready <1896.697170952@dbc.mtview.ca.us>
         C: APOP mrose c4c9334bac560ecc979e58001b3e22fb
         S: +OK maildrop has 1 message (369 octets)

         In this example, the shared  secret  is  the  string  `tan-
         staaf'.  Hence, the MD5 algorithm is applied to the string

            <1896.697170952@dbc.mtview.ca.us>tanstaaf

         which produces a digest value of

            c4c9334bac560ecc979e58001b3e22fb //this is what we need in Java
S:+OK POP3服务器就绪
C:APOP mrose c4c9334bac560ecc979e58001b3e22fb
S:+OK maildrop有一条消息(369个八位字节)
在本例中,共享秘密是字符串`tan-
斯塔夫'。因此,MD5算法应用于字符串
坦斯塔夫
它生成的摘要值为
c4c9334bac560ecc979e58001b3e22fb//这就是我们在Java中需要的
在此之后,如何获取每条消息的MessageID/UID

我需要的示例消息ID。一个不推荐使用的fuego.mail库以前为我们提供了以下内容:

<F855F5879C6E754E9DE37F2E7D0762327C942B43@GADC-EMB099.ap.abc‌​.com> 

更新 我用这个时得到了一个3位数的整数,即561

Store store = emailSession.getStore(MAILSTORETYPE);

            store.connect(HOST, USERNAME, PASSWORD);

            Folder emailFolder = store.getFolder("INBOX");
            emailFolder.open(Folder.READ_ONLY);

            FetchProfile fp = new FetchProfile();
            fp.add(UIDFolder.FetchProfileItem.UID);
            emailFolder.fetch(emailFolder.getMessages(), fp);

            POP3Folder pf =(POP3Folder)emailFolder;         

            Message[] messages = emailFolder.getMessages();

            for (int i = 0, n = messages.length; i < n; i++) {
                Message message = messages[i];

                    String uid = pf.getUID(message);
                    System.out.println(uid);
Store Store=emailSession.getStore(MAILSTORETYPE);
store.connect(主机、用户名、密码);
文件夹emailFolder=store.getFolder(“收件箱”);
emailFolder.open(文件夹只读);
FetchProfile fp=新的FetchProfile();
fp.add(UIDFolder.FetchProfileItem.UID);
emailFolder.fetch(emailFolder.getMessages(),fp);
POP3文件夹pf=(POP3文件夹)电子邮件文件夹;
Message[]messages=emailFolder.getMessages();
for(int i=0,n=messages.length;i
好的,您已经复制了一份与邮件UID相关的jamavail文档摘录,当服务器支持可选命令
UIDL
时可以使用该摘录,以及一份与
APOP
身份验证相关的RFC1939摘录。您的问题到底是什么?如何构建
APOP
摘要或如何获取邮件UID。这些都是完整的完全不相关。没有进一步的细节,这个问题不清楚。请注意,如果这是您想要的。请注意,POP3 UID与邮件中的邮件ID标头不同。@SergeBallesta我需要使用Java获取POP3协议邮箱中邮件的邮件ID。@SergeBallesta我添加了此引用,因为它们是我的研究。我认为他们会找到解决方案。第一部分(javamail javadoc)应该会找到解决方案。你试过编码吗?但是要注意,正如BillShannon所说,你得到的可能不是你所期望的:POP3 UIDL与消息ID头无关。