Jérôme Belleman
Home  •  Tools  •  Posts  •  Talks  •  Travels  •  Graphics  •  About Me

Juggling Gmail with Mutt

4 May 2017

The IMAP service offered by Gmail isn't conventional and you're in for a few surprises if you don't understand what it does with your mail behind the scenes.

1 Sent Mail

In a classic IMAP server, you'd set up mutt to record your sent mail into a mailbox called something like Sent. However, you will find that Gmail will keep a copy of your sent mail whether you want it or not. In that case, you had better make sure that mutt doesn't try to make yet another one:

unset record

2 Not Mailboxes, Labels

Gmail doesn't use mailboxes as such, but labels. A message can have multiple labels. From the perspective of mutt, it means that a given message can be in several mailboxes. This label approach does have a number of unexpected consequences when using a mailer expecting a more traditional IMAP server. But you'll find you can edit a message label with mutt by moving it between mailboxes. For instance:

3 Deleting Mail

If you do not set the mutt trash variable, removing a message from a mailbox doesn't delete it from Gmail, it merely removes the corresponding label. One way to eventually delete a message from Gmail with mutt is to move it to the Trash by giving it the Trash label, which will cause it to vanish after 30 days:

set trash=imaps://john.doe@imap.gmail.com/[Gmail]/Trash;

Rather appropriately, giving a message the Trash label causes it to lose all its other labels in the process, meaning that you won't see it in any other mailboxes anymore.

If your ~/.muttrc sets up connections for other, more conventional IMAP servers, make sure to unset trash for these ones, because you're normally better off deleting mail right off rather than moving it to a so-called Trash. That concept of trashes in computing is an endless source of confusion for everyone.