Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How reliable are IMAP UIDs?

I'm writing an IMAP crawler, which is part of an Open Source app, and for incremental crawling I'd like to use the message UIDs to find out whether I've already seen a particular message or not.

Now I found a post from 2007 that says IMAP UIDs aren't always reliable. More specifically, if the flag UIDNOTSTICKY is set, you can't assume the UIDs are always the same. So my question is, do I have to take the case UIDNOTSTICKY=true seriously, or are IMAP servers with non-sticky UIDs legacy stuff and not in (widespread) use anymore?

like image 211
python dude Avatar asked Feb 26 '23 13:02

python dude


1 Answers

If the UIDNOTSTICKY response code is returned during a SELECT or EXAMINE, you'll also see that the UIDVALIDITY value on the mailbox (the IMAP term for a folder) changes every time you SELECT or EXAMINE the mailbox. But you have to check for a change in UIDVALIDITY anyway since the mailbox's UIDVALIDITY is not guaranteed immutable, and any such change invalidates your cached UIDs. Yes, UIDVALIDITY values generally don't change. But your code's going to have to deal with that case, and by doing so you'll have also covered the UIDNOTSTICKY case.

like image 81
dkarp Avatar answered Mar 16 '23 11:03

dkarp