Copyright © 1999–2018 FastMail Pty Ltd
This is a technical post. Regular FastMail users subscribed to receive email updates from the FastMail blog can just ignore this post.
We’ve recently been testing out the Mail application in iOS 7 and found that there’s been a couple of significant changes, especially when you search your email. If you run an IMAP server with users that connect using the iOS Mail application, you might be interested in what we found. The two main ones are:
- Rather than searching the current folder, by default, it searches all folders. To do that, it opens many IMAP connections at once for searching each folder concurrently. We're not sure on the upper bound on the number of connections it will make, but saw at least 10 in one case.
- Rather than searching the Subject/To/Cc/From fields, by default, it searches all those fields as well as the message body.
Both of these changes are actually great for the user experience, but they create potentially large headaches for IMAP server maintainers.
Clients making multiple IMAP connections at once isn’t new, but the number of potential IMAP connections an iOS client might now make is large. Some administrators limit the total number of IMAP connections a user can make at once. They might have to raise this or iOS might start returning unexpected results.
The bigger concern is the body searching. The search string iOS now sends is:
tag UID SEARCH RETURN (ALL) (OR FROM "Foo" (OR SUBJECT "Foo" (OR TO "Foo" (OR CC "Foo" BODY "Foo")))) NOT DELETED
IMAP search semantics suggest that a body search is supposed to be a
pure sub-string search (BODY \
Our plan at FastMail is to detect iOS clients, and convert all searches into FUZZY searches. This causes matches to be done on “terms” rather than pure sub-strings, but allows us to use our xapian powered index which should make matching and fetching results much, much quicker.