Monday Jul 28, 2008

The answer is still no, firmware 2.0 on the iPhone does not appear to support IMAP IDLE. The push email feature works only with Microsoft Exchange, MobileMe, and Yahoo!. If you go to Settings > Fetch New Data > Advanced, and select an IMAP server, only two choices are given: Fetch [periodically] or Manual. No Push. This is reaffirmed by my IMAP telemetry log. Just like in firmware 1.x, iPhone's mail client never sends the IDLE command.

Since I installed the new firmware on my original iPhone, I've noticed drastic battery life reduction. Following Apple's advice, I turned off push email and saw significant improvement. With push email enabled, I had to recharge it almost daily; now my iPhone can go 2-3 days between charges, which is still more frequent than, but closer to my experience on 1.x firmware.

Wednesday Apr 23, 2008

To facilitate push Email to mobile devices? I'm doubtful, here are the reasons:

First, IMAP IDLE relies on keeping the IMAP connection alive. Mobile devices are more likely than desktop clients to experience network errors and timeouts as they travel. And devices capable of both Wi-Fi and cellular, like Apple's iPhone, automatically switches from one network to the other, terminating the connection as they do so. I feel that a true push solution should not depend on a persistent connection.

Second, an IMAP IDLE session only monitors a single mailbox. If you need to watch multiple folders simultaneously (like if you use server-side filtering or subaddressing), you need multiple sessions. Is any client capable of that?

Third, maintaining the session not only drains the battery, of which mobile devices have limited amount, it also hogs the data channels so I don't think telcos like that idea very much.

Michael told me OMA-EMN uses sideband SMS for notification, so it's designed to be friendlier to battery and network operators compare to IMAP IDLE. But I've yet to come across a client that supports OMA-EMN.

Thursday Feb 21, 2008

This is a follow-up and correction to my previous post: iPhone supports IMAP IDLE.

After more testing, turns out iPhone does not support IMAP IDLE (on a Wi-Fi connection, firmware 1.1.3), it instead Auto-Checks every 2-5 minutes despite the Setting says don't. I verified this by enabling IMAP telemetry in Dovecot 1.0 through its rawlog facility. Even though the server advertises IDLE in its CAPABILITY response, iPhone's client never issues the IDLE command.

Is that a loss? Probably not. According to this thread, beta testers of the iMapIdle utility report significant battery drain while IDLE runs on a Wi-Fi connection. On an EDGE connection, the drain is not as bad. But when iPhone switches between Wi-Fi and EDGE, the IDLE session gets dropped. For these reasons, I can see why Apple designers chose to not implement IMAP IDLE on iPhone.

Friday Nov 02, 2007

Now that IMAP IDLE support in Gmail is confirmed, the logical next step is to see if iPhone supports it as well, and more importantly perhaps, how much value does it add over client-side polling? The short answer is yes, iPhone has IMAP IDLE, but updates don't come in real time. Here's how I tested it (on a Wi-Fi connection, firmware 1.1.1):

  1. Under Settings -> Mail, make sure Auto-Check is set to Manual
  2. Under Settings -> General, make sure Auto-Lock is set of Never
  3. Open my Gmail Inbox on the iPhone
  4. Create an IMAP IDLE session to my Gmail Inbox using openssl(1)
  5. Send a test message to my Gmail account

I repeated the test 3 times. The messages took 2-4 minutes to show up on the iPhone so there's quite a bit of delay. Header information shows end-to-end delivery times of 3-14 seconds so the delay isn't in SMTP. In the IMAP IDLE session, the server transmitted updates also within seconds so the delay isn't in IMAP either. I believe it's fair to conclude that the delay is caused by iPhone, specifically the way it handles IMAP IDLE. My guess is the designers opted for battery conservation over speed of new mail notification.

Then how much better is push IMAP than pull IMAP? Based on the above, I'd have to say not much, at least not on iPhone.


[UPDATE Feb 21, 2008] Part 2: turns out iPhone does not support IDLE.

Wednesday Oct 31, 2007

About a week after Gmail begins enabling IMAP, my account has it.

To my surprise, Gmail implemented IMAP IDLE:

~$ openssl s_client -crlf -quiet -connect imap.gmail.com:993
depth=0 /C=US/ST=California/L=Mountain View/O=Google Inc/CN=imap.gmail.com
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 /C=US/ST=California/L=Mountain View/O=Google Inc/CN=imap.gmail.com
verify error:num=27:certificate not trusted
verify return:1
depth=0 /C=US/ST=California/L=Mountain View/O=Google Inc/CN=imap.gmail.com
verify error:num=21:unable to verify the first certificate
verify return:1
* OK Gimap ready for requests from 11.22.33.44 q196f2e0411bog
. capability
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA XYZZY
. OK Thats all she wrote! q196f2e0411bog
. login username password
. OK username@gmail.com authenticated (Success)
. examine inbox
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen \*)
* OK [PERMANENTFLAGS ()]
* OK [UIDVALIDITY 594706426]
* 469 EXISTS
* 0 RECENT
* OK [UNSEEN 1]
* OK [UIDNEXT 772]
. OK [READ-ONLY] inbox selected. (Success)
. idle
+ idling
(some time passes while I send myself a test message)
* 470 EXISTS

I wonder what XYZZY does.


[UPDATE Feb 21, 2008] They added two more IMAP extensions:

. capability
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA XLIST CHILDREN XYZZY

What does XLIST do?

This blog copyright 2009 by chienr