IMAP

最後更新: 2021-12-28

目錄

  • IMAP - idle
  • IMAP - purge
  • CLI - EXAMINE(UidValidity)

 


IMAP - idle

 

IDLE is an IMAP feature

IMAP4 servers that support IDLE will include the programming string "IDLE" in the result of their CAPABILITY command.

When configuring folders for PUSH mail (IMAP IDLE) in K-9 Mail, it keeps one IMAP connection open for every folder.

allows a client to indicate to the server that it is ready to accept real-time notifications. <-- Push-IMAP

synchronize messages between the two by using an open connection that is kept alive by some kind of heartbeat

IMAPv4 Rev1 (RFC 3501)
* it uses compression and command macros

 

Testing:

. login xxx@xxx pw
. select inbox
. idle
+ idling
* OK Still here
* 18 EXISTS
* 4 RECENT

* The IDLE command eliminates the need for a e-mail client to poll for new mail

 

002 idle
+ idling
* OK Still here
* OK Still here
done
002 OK Idle completed.

...........................

005 idle
+ idling
# 打錯野後
005 BAD Expected DONE.

server requests a response to the IDLE command using the continuation
("+") response. 

The IDLE command remains active until the client responds to the Server "DONE"
* DONE 前面不用加 SN

clients using IDLE are advised to terminate the IDLE and re-issue it at least every 29 minutes to avoid being logged off.

 


NOOP Command

Since any command can return a status update as untagged data, the
NOOP command can be used as a periodic poll for new messages or
message status updates during a period of inactivity (this is the
preferred method to do this).  The NOOP command can also be used
to reset any inactivity autologout timer on the server.

 


Dovecot Fix

 

protocol imap {
 # How long to wait between "OK Still here" notifications when client is
 # IDLEing.
 #imap_idle_notify_interval = 2 mins
}

# How many seconds to wait between "OK Still here" notifications when client is IDLEing.

K-9 mail by default refreshes IDLE connections every 24 minutes,

but of course Dovecot wakes up the client much more frequently than that.
We are going to fix this behavoir.

mail.check_all_imap_folders_for_new to true

The server responds to the idle command when there is a new message (or messages) which indicates to the client that there are new messages.

When the user is inactive, and does not wish to receive notifications, the client simply stops using IDLE, which is very efficient.

* IMAP server timeout: Typically occurs after 30 minutes with no activity.
* NAT Gateway timeout

IMAP client to issue a NOOP (No Operation) command at intervals

lose IP network connectivity from time to time, and this will need to be automatically re-established, and the IMAP connection re-established

 

Outlook 2010

Navigate to File >> Options >> Advanced >> scroll down to the send/receive heading >> click on the send/receive button on the right
On the right hand side of the send/receive groups window that opens click on the Edit button
Un-check the "Get folder unread count for subscribed folders"

Doc

http://tools.ietf.org/html/rfc2177

 


IMAP - purge

 

Outlook

 

menu
View -> Current View -> Hide Messages Marked for Deletion.

* If you do not purge the deleted items periodically, you might reach and exceed the allotted disk space on your e-mail server.

Manually purge deleted items

menu
Edit -> Purge Deleted Messages

 


CLI - EXAMINE(UidValidity)

 

UidValidity Property

the client should remember UidValidity value of each folder and compare the saved value and new value on next session.

If new value is larger, it means the mail server is not capable of keeping UIDs unchanged between sessions.

In this case, the client cannot make any assumptions that UIDs obtained during the previous session correspond to UIDs of the same messages on this session.

Nowadays, IMAP4 servers which fail to persist UIDs between session are very uncommon, and the UIDVALIDITY value is usually the same accross sessions.

Nevertheless, the client should still check the UIDVALIDITY value due to the following reason: if, between two sessions, the folder was deleted and the folder with the same name was recreated, and this new folder was filled with some mails, their UIDs may coincide with UIDs of the messages in the original folder (which is now deleted). To avoid confusion, the application should check if UIDVALIDITY had changed.

 

 

Creative Commons license icon Creative Commons license icon