Juggling Gmail with Mutt
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:
- Saving a message with s , which normally causes it to be removed from the current mailbox and saved to the destination one will have Gmail remove its current label and give it the destination one instead, as expected.
- Copying a message with Shift c , which normally causes it to be copied to the destination mailbox will have Gmail add it the destination label. This is a slightly more nerve-racking thought, as from the mutt standpoint, the copy becomes a message in its own right, whereas from the point of view of Gmail, it's one and only message with two labels. But the distinction just doesn't matter for all practical purposes. And when you think about it, mutt will show the same
Message-ID
for both copies anyway.
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.