问题
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