6

I'm using Net::POP3 in Perl to iterate through a mailbox on an MS Exchange server. I run the UIDL command on each message number and compare the ID returned to previously-seen IDs to see if I've dealt with this message in the past. However, I'm also finding that within an individual POP3 mailbox, the same UID seems to come up multiple times for different messages.

Any idea why this might be happening? Is the UID not truly unique? Or are the messages somehow being duplicated within the same mailbox?

Peter Wood
  • 163
  • 1
  • 8

1 Answers1

3

The RFC says:

While it is generally preferable for server implementations to store arbitrarily assigned unique-ids in the maildrop, this specification is intended to permit unique-ids to be calculated as a hash of the message. Clients should be able to handle a situation where two identical copies of a message in a maildrop have the same unique-id.

[my emphasis]

Community
  • 1
  • 1
hlovdal
  • 26,565
  • 10
  • 94
  • 165
  • Thanks, that's just what I was looking for. It seems that I'm handling things properly, then, in that when I come across an already-seen UID, I'm treating it as a duplicate and ignoring the message. A tangential question would be: "How does this sort of duplicate message occur?" But that's outside the scope of the original question. – Peter Wood Apr 17 '09 at 19:14
  • @Peter Wood Just a quick tip - make sure the UID lookup query is looking for a case sensitive match. I've had problems because the default behavior was case insensitive, which caused my code to wrongfully ignore certain e-mails. – Matt Refghi Oct 06 '09 at 18:54
  • That scenario of identical messages actually happens in practice? When I read that passage in the RFC, I thought that it would only ever be a strictly theoretical situation because of all the timestamps and IDs that servers write into the header. – billpg Nov 12 '10 at 16:18
  • Perhaps you can combine this with `TOP [id] 1` to get the headers and check to see if the message-id or date + from + subject differ. – Xeoncross May 03 '13 at 14:39