Copyright © 1999–2018 FastMail Pty Ltd
This post contains some observations about how the mail application in iOS 5 appears to interact with IMAP servers. We're posting this mostly as a reference for people interested.
In iOS settings, you can choose a "fetch interval", which is:
- Manually (never fetches automatically)
- Every 15 minutes
- Every 30 minutes
- Every hour
- Push (only shown on servers supporting it, which I believe is currently only Exchange servers or Yahoo Mail)
If you choose "Manually", then there is no persistent connection once you exit the mail app.
If you choose any other interval, then a background daemon holds a persistent connection to the mail server. We don't know exactly why they hold the connection open, and we're not sure if it leaves the connection in IDLE state to get updates pushed to it. The main advantage of holding it open is probably skipping the overhead of re-authenticating/handshaking, but there's also no good reason to explicitly close the connection after every fetch given that IMAP is supposed to be long-lived.
If you have these fetch intervals set, and then break your network connection, then iOS will attempt to reconnect the next time it wants to fetch your mail again.
Note that the intervals listed appear to be only approximate. iOS appears to be smart about batching requests together, so it gets as much work done as it can while the phone is awake or the network connection is "up". Also, opening the mail app, or opening a folder in the mail app, will often trigger a refresh too.