Closed piher closed 12 years ago
That UID is not a global. As far as I'm aware, it's only unique for the duration of the connection, and only IMAP provides it. It isn't part of the actual message data, which is why it isn't persisted.
I thought that the uid was a "unique id" that the server would give to each email received in order to easily browse the server's messages (ie unique but only for the current mail account). Wikipedia tends to say so too but I admit that I have no advanced network knowledge nor serious source to support my opinion.
About POP3 and IMAP uids : "Clients that leave mail on servers generally use the UIDL command to get the current association of message-numbers to message identified by its unique identifier. The unique identifier is arbitrary, and might be repeated if the mailbox contains identical messages. In contrast, IMAP uses a 32-bit unique identifier (UID) that is assigned to messages in ascending (although not necessarily consecutive) order as they are received. When retrieving new messages, an IMAP client requests the UIDs greater than the highest UID among all previously-retrieved messages, whereas a POP client must fetch the entire UIDL map. For large mailboxes, this can require significant processing." (Wikipedia)
Anyway, I can still use the message-id which is supposed to be unique on the whole web but it's more heavy and doesn't allow me to know quickly if a message is prior to another one.
Well, I know that in Gmail, their "UID" is only unique for a connection. What about using the MailMessage.Date
property for this?
-----Original Message----- From: piher [mailto:reply@reply.github.com] Sent: Friday, January 06, 2012 10:20 AM To: Andy Edinborough Subject: Re: [aenetmail] Load method not loading uid ? (#19)
I thought that the uid was a "unique id" that the server would give to each email received in order to easily browse the server's messages (ie unique but only for the current mail account). Wikipedia tends to say so too but I admit that I have no advanced network knowledge nor serious source to support my opinion.
About POP3 and IMAP uids : "Clients that leave mail on servers generally use the UIDL command to get the current association of message-numbers to message identified by its unique identifier. The unique identifier is arbitrary, and might be repeated if the mailbox contains identical messages. In contrast, IMAP uses a 32-bit unique identifier (UID) that is assigned to messages in ascending (although not necessarily consecutive) order as they are received. When retrieving new messages, an IMAP client requests the UIDs greater than the highest UID among all previously-retrieved messages, whereas a POP client must fetch the entire UIDL map. For large mailboxes, this can require significant processing." (Wikipedia)
Anyway, I can still use the message-id which is supposed to be unique on the whole web but it's more heavy and doesn't allow me to know quickly if a message is prior to another one.
Reply to this email directly or view it on GitHub: https://github.com/andyedinborough/aenetmail/issues/19#issuecomment-3386658
Okay that's good to know. Ordering the messages was not really an issue, it would have been more simple using a uid but that's no big deal I can use the date as you said. My problematic was about saving the emails and associating an id to each of them to know which ones I've already fetched but i guess i'll juste use the message-id property for that.
Thanks anyway
but be aware that message-id is not a mandatory header field. the only unique id of a message is the UID together with the UIDVALIDITY of a mailbox.
As RFC3501 specifies (http://tools.ietf.org/html/rfc3501#page-8) no UID will change during sessions. And no UID will ever be used by an IMAP server again.
The thing is that only server side knows the UID. So there is no header property which contains the UID.
Ok, then how should I know if a message from the server is already saved in my local email database ?
It's quite easy, you must cache locally all UID's which was synced so far.
Please also refer to this informational paper regarding synchronisation between IMAP server and client. For me it was very helpful: http://tools.ietf.org/html/rfc4549
best regards
I'm sorry but I don't get it. That's what I was doing but what I understood from Andy's remarks and yours is that according to the rfc, the UID of a message is not necessarily the same between two sessions...
rfc specifies that the UID MUST NOT change during a session and SHOULD NOT change between sessions. I figured out that gmail for example doesn't change UIDs between the sessions.
If you gonna use your client as gmail only for example you can also refer to Google's unique msg-id: http://code.google.com/apis/gmail/imap/#x-gm-msgid
That's what I'm saying, but the thing is I don't know which email provider my users will use. Therefor, I was looking for a way to permanently identify each message. But if the uid is not always unique and if the message-id is not mandatory... I guess the only 100% valid way is to compare the headers (and yet, the server may contain identical messages), which seems like a very slow method...
Ok. Now I got you. I was excactly faced to the same issue. But I belive that in common the UID will not be changed by the different IMAP providers.
That would be a big pitfall for every IMAP client implementation....
Hmm... I guess that leaves me with one option : hoping that every imap server used respects the unique uid...
You could rely on the message-ID header and when it's not present, generate it and store it on the server.
On Jan 16, 2012, at 5:41 AM, "piher" reply@reply.github.com wrote:
Hmm... I guess that leaves me with one option : hoping that every imap server used respects the unique uid...
Reply to this email directly or view it on GitHub: https://github.com/andyedinborough/aenetmail/issues/19#issuecomment-3509538
I would not prefer the usage of message-Ids for identifying messages.
At least you can't use message-id for updating the message on the IMAP server eg. for marking or deleting. even a FETCH command isn't possible with message-id.
Right, you would use UID for communications within a session to the server, but for determining whether a message exists in a local store, you'd have to use message-ID.
Hello,
When i save the raw text of a downloaded email and then later try to load it, everything's fine except that the uid is nothing. After giving a quick look at the source code I believe that the load method of a MailMessage forgets to load its uid.