What is the difference between IMAPMessage.getUID() and Message-ID header?

懵懂的女人 提交于 2020-08-25 07:32:46

问题


What is the difference between these two from java mail perspective? I can see that 2 values are not same for a particular message. So what should I consider an IMAP message's unique id?

If I need to fetch message from an IMAP server corresponding to an unique id, should I use?

MessageIDTerm

or

IMAPFolder.getMessageByUID()

回答1:


UID is the unique identification number of a email in a IMAP folder. Each mail in a folder is assigned a uid, it is you can say a index maintained by the mail folder. Whereas message-id is a header part of a email.

To understand in a simple term, UID is a unique number which cannot be duplicated within a folder. If I copy same email twice in a folder, each will have same headers having same message-id but will have a different UID.

Other major difference is,

  • UID's are assigned by a imap server
  • MessageId's are set by the email client.

So it is always better to rely on a UID to extract the email.

Refer : RFC - UID



来源:https://stackoverflow.com/questions/37162681/what-is-the-difference-between-imapmessage-getuid-and-message-id-header

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!