Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

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.

share|improve this answer
    
You mean the Message-ID email header, not the UID returned by IMAP. Hmm. –  Ken 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
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.