macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Using IMAP on Mac OS X
Pages: 1, 2, 3

Organizing Mailboxes

In the mailbox list underneath an IMAP account's header, you'll find a list containing an inbox, any mailboxes you create, and any mailboxes Mail.app creates in order to support some of its own special features.

Inbox

An IMAP server abstracts all a user's new and otherwise unsorted mail into a single mailbox called inbox, so you'll always have at least this mailbox available to you.

Creating and Editing IMAP Mailboxes

Mail.app's commands for creating and organizing mailboxes and folders, found under the Mailbox menu, remains consistent across all its account types, IMAP included. When you create, rename, and delete mailboxes through the commands in this menu, or move mailboxes around by dragging their icons in the mailbox list drawer, Mail.app echoes these actions on your IMAP account's structure. Thus, all the changes you make in one session with Mail.app will carry across to any future connections you make to this IMAP account with any mail client.

Special Mailboxes

While Mail.app takes full advantage of IMAP's ability to let you create and organize mailboxes any way you like, the application also has the ability to map its own functionality onto some special server-side mailboxes, if you let it. In all of the following cases, Mail.app will create these mailboxes on the server as necessary.

Drafts

By default, messages that you save as a draft (through File->Save As Draft (-S), or the message window's Save As Draft toolbar button) stay in Mail.app's special Outbox mailbox, stored only on your Mac. If you wish, you can instead store unfinished messages on an IMAP mailbox, so they'll be available to choose and complete from other machines.


Figure 5.

To do this, call up the Composing tab of Mail->Preferences as seen in Figure 5, and select one of your IMAP mailboxes from the Save unsent mail in: pull-down menu.

Tip

As you can see in Figure 4, I gave my drafts mailbox a leading exclamation point in its name, for the simple reason that !drafts will always appear at the top of the alphabetically-sorted list of server-side mailboxes, and I didn't want it mixed in with that list. (Of course, I did that before I got around to sorting all my other mailboxes into their own folders, which makes them all stand apart anyway. Oh well. It made sense at the time.)

Sent Messages

It's worth noting that Mail.app does not keep its Sent Messages mailbox on the IMAP server; it's only on your Mac. Mail.app stores copies of all the mail you send through all your accounts, IMAP and otherwise, here.

If you want to keep server-side copies of sent mail, choose an IMAP mailbox from the Save sent mail in: pull-down menu found under the Preference panel's Composing tab (Figure 5).

Trash Mailbox

If you have the Move deleted mail to a folder named: checkbox set under the Viewing tab of Mail-->Preferences..., then Mail.app will create a folder on the server to serve as a trashcan, where deleted mail will move itself. It will name this folder either Deleted Messages, Deleted Items, or Trash, depending on your selection from that checkbox's attached pull-down menu (Figure 6).


Figure 6.

You don't need to have a special folder for maintaining deleted messages since IMAP lets you store deleted mail in any mailbox, as described in the section called "Deleting Messages." However, Mail.app doesn't let you see any deleted messages except for ones in this special mailbox, and only if you have this checkbox activated.

Organizing Messages

An email message sitting in an IMAP mailbox can have some number of message flags set on it, recording the actions performed on this message, such as the user's reading, replying to, or deleting it. When you reply to a message on your office PC, for example, and then later connect to your mailbox at home, that message will "remember" the fact you already replied to it, and be able to report this to you.

Mail.app works with most flags in a fairly straightforward fashion, but gets a little squirrelly when it comes to IMAP's Deleted flag, as we shall see.

Note: There's nothing particularly magic about how message flags work; they exist simply as headers the IMAP server adds to the messages on its end as their status changes.

Message Flags

Mail.app displays IMAP flags through symbols in the Flag and Status columns of a mailbox's message list, as shown in Figure 7. The following list uses the flag names as they're defined by the IMAP standard, and explains how Mail.app represents them.


Figure 7.
Recent

A message gets a Recent flag if the current IMAP connection is the first to have seen it. Mail.app places a blue dot in this message's status column, marking it as a new, unread message. Mail.app unsets this flag once the user reads a message.

Seen

A message with a Seen flag has been read.

Mail.app reacts to the absence of this flag; a message lacking a Seen flag (which all Recent messages do, by definition) gets a blue dot. Mail.app does not distinguish between unread mail that arrived since the current session started (and has a Recent flag) and unread mail carried over from a previous IMAP session (and therefore has no message flags).

Related Reading

Learning Unix for Mac OS X
By Dave Taylor, Jerry Peek

Selecting Message-->Mark As Unread (Option--M) removes this flag from selected messages, and Message-->Mark As Read (Option--M) sets it. (One of these two commands appears in the Message menu, depending upon the status of the selected messages.)

Answered

Replying to an IMAP message prompts Mail.app to set its Answered flag. Mail.app displays such messages with a little U-turn arrow in its status column, unless the message lacks a Seen flag.

Flagged

The Flagged flag can mean whatever you want. Generally, it's meant to signal that a message requires urgent attention.

In Mail.app, you can toggle this flag for the selected message(s) through Message-->Mark As (Un)Flagged (Option--G). Flagged messages receive little flag icons in the message list's flag column (see Figure 7).

Draft

Mail.app sets a message's Draft flag if it's an unfinished, unsent message you're storing in an IMAP mailbox, as described in the section called "Drafts".

Deleted

Mail.app gives messages Delete flags when you delete them (through the Delete key, or Message-->Delete, or dragging them into your dock's Trash icon). This seems fairly straightforward, and it does more or less what you want, but this flag's actual implications are convoluted enough that this article dedicates a whole section to the topic: see the section called "Deleting Messages".

Deleting Messages

IMAP uses a two-step process for deleting messages. Any message can set a Deleted flag on itself, which marks it as susceptible to actual deletion, but doesn't actually get rid of it or even move it out of its original mailbox. A separate IMAP command purges a mailbox of all the deleted messages it contains.

Different mail clients have different ways of representing deleted (but not yet erased) messages to the user. Mail.app chooses to simply not show deleted mail at all, unless it's inside the designated "trash" mailbox, as described in the section called "Trash Mailbox".

Mail.app's IMAP response to deleting mail changes depending upon how you've set the Move deleted mail to a folder named: checkbox seen in Figure 6. If you've checked it, then deleting a piece of mail will cause Mail.app to move it to your chosen trash mailbox, rather than setting its Delete flag.

If you've instead left that checkbox unchecked, then Mail.app will set the message's Deleted flags, but otherwise leave them be. Since Mail.app refuses to display deleted mail in mailboxes other than the trash mailbox, this action will also make the message vanish from sight, even though it continues to exist on the server (and perhaps remain visible to other mail clients).

That same checkbox also dictates Mail.app's behavior with actually erasing deleted messages. If checked, then Mail.app gives you a Mailbox-->Empty Trash Mailbox (-K) command. This will have Mail.app send the IMAP EXPUNGE command to its trash mailbox, and since it contains only messages with the Deleted flags set, they'll all go away (unless you've been weird and snuck other mail in there through sneaky means; those would stick around). Deleted messages in other mailboxes, however, simply remain present and invisible to you, at least so long as you use Mail.app as your client.

If you leave this box unchecked, then Mail.app instead offers the Mailbox-->Compact Mailbox (-K) command. This will simply expunge the selected mailbox, permanently erasing all its unseen deleted messages, and seeming to shrink the mailbox's size without affecting any of its visible messages. ("Compact", in this case, is Mail.app's positive way of spinning the fact that it doesn't have a way of dealing with deleted mail in arbitrary IMAP mailboxes, and so they appear as so much dead weight.)

Note that both these commands share the -K keybinding, so hitting this combo will always erase deleted mail, one way or another.

Using IMAP Securely

Like POP, IMAP offers no built-in security mechanisms, meaning that network eavesdroppers may be able to obtain your account password when you fetch mail. Depending upon the services your mailhost provides, though, you may be able to avoid this attack by using IMAP over a secure, encrypted network connection. See my earlier article, Secure Mail Reading on Mac OS X, for details.

References

The IETF maintains the RFC documents that define the standards of POP and IMAP (and most every other technology the Internet uses).

POP

Version 3 of the Post Office Protocol is defined in IETF RFC 1939.

IMAP

Version 4 of the Internet Message Access Protocol is defined in IETF RFC 2060.

The IMAP Connection at the University of Washington (IMAP's alma mater, where the protocol was first drafted and implemented by Mark Crispin) serves as a comprehensive information repository regarding all things IMAP.

Thanks to Jason Lavoie for assistance with this article.

Jason McIntosh lives and works in and around Boston. He has co-authored two O'Reilly books, Mac OS X in a Nutshell and Perl & XML.


Return to MacDevCenter.com.