2

The background is, I'm trying to migrate mail between two IMAP servers and I want to make sure that in the event of a re-retry, a duplicate message isn't migrated again. What I'd like is to query each IMAP server for something equivalent to the md5 of the raw email, so I can compare which emails have been migrated and which have not.

Is something like that possible in IMAP4? I see the UID, but that seems to only be unique to the server, not really a unique identifier of the content.

Ken Kinder
  • 121
  • 3

3 Answers3

2

Message-IDs should be unique, but that's not guaranteed at all, and there are plenty broken mail programs on the planet. If you have to be absolutely certain, verify the checksum yourself, in other cases the Message-ID could and should be sufficient.

arjarj
  • 3,101
  • 1
  • 17
  • 10
  • You mean the Message-ID email header, not the UID returned by IMAP. Hmm. – Ken Kinder Sep 23 '11 at 20:51
  • Yes, I meant the Message-ID header indeed. It's supposed to be present and unique, but unfortunately it can be missing or duplicate. Mails can be copied, and headers can be skipped or forgotten. – arjarj Sep 23 '11 at 21:04
2

Still a decent bit of downloading to be done, but try fetching BODY.PEEK[HEADER] of the message to get just the header section, and compare the Message-ID header.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
1

You probably want to check the "Message-ID" header value. This isn't quite the same as an MD5 of the entire message, but each unique message should have a unique ID value; so it's safe to assume that if you see a message id on the destination server, the message has already been copied.

Coding Gorilla
  • 1,938
  • 12
  • 10