IMAP utilities

From Peyton Hall Documentation

Jump to: navigation, search

There are some basic IMAP utilities installed on the network to make managing your email simpler. Here we'll go over them and their usage.

NOTE:

A handier way to get your mail off the IMAP server, if you're so inclined, is to use Fetchmail to download it. See this section for more details: Fetchmail


Contents

Usage

Common to all utilities

For ALL the IMAP utilities, one of the arguments is the mailbox name. There's a specific convention used for mailbox names, which I'll go over here.

First, the hostname of the IMAP server, which is enclosed in curly braces like this: {mail}

NOTE:

The fully qualified domain name (FQDN) is not necessary on most machines, so {mail} works just as well as {mail.astro.princeton.edu}

The next part is the mailbox name. Note that if you have sub-mailboxes, the field separator is a period, and that all folders are 'children' of your inbox. So if you have a folder called "lists", and in that you wish to refer to the folder "bugtraq", you would reference it as {mail}INBOX.lists.bugtraq.

The programs will then ask for your user name and password. One way to keep it from asking for the user name every time is to supply it in with the name of the server with the /user flag, like this: {mail/user=huston}

Then it will only ask for the password on the mailbox. This is especially handy if you write aliases to check certain things with mail, or write scripts, so you only have to type in your password.

Also note that in most shells, the mailbox would have to be in single quotes to keep the shell from doing funny things to the text in the braces.


icat

icat will work like 'cat' on an IMAP mailbox. What's more, it can also work like grep, but will report the entire message instead of just the line containing the string. You can filter messages by date, status (answered, deleted, flagged, new, not new), or where a certain case-insensitive string is (To:, Subject, CC, From, body, all). 'man icat' for usage information.


chkmail

The chkmail program will check for new mail in the specified mailbox. 'man chkmail' for usage information.


ifrom

ifrom is very handy, as it prints a one-liner for every message in the specified mailbox, containing the message number, status, From: header, date, and subject. 'man ifrom' for usage information.


imapcopy / imapmove

imapcopy and imapmove copy (and move) messages from the IMAP inbox on the named host to the destination mailbox. They both require that the destination mailbox exists, otherwise they'll print an error message and exit. This is good if you want to copy all messages from a folder on the IMAP server to a file for backup, or to archive old mail to a file and move it offline. The target mailbox can also be another IMAP folder. However the source is only the inbox. 'man imapcopy' for more.


imapxfer

imapxfer copies mailboxes between IMAP servers. Not entirely useful, unless you want to move your mail from an old machine to a new one. This will copy *everything* over from the source to the destination, and mailboxes are created on the destination host if they don't already exist. 'man imapxfer' for more.


mbxcopy / mbxmove

mbxcopy and mbxmove copy (or move) messages to a new mailbox. The destination must *not* already exist, or it will fail with an error message. The destination mailbox will be created. Since these commands take any kind of mailbox as an argument for source and destination, they are ideal for importing mbox-style message folders onto an IMAP server. For example, to copy a local folder named sent-messages to your sent-messages folder on the IMAP server, use:

mbxcopy ~/mail/sent-messages '{mail}INBOX.sent-messages'


mbxcreat

To create a new mailbox from the commandline, use 'mbxcreat'. 'man mbxcreat' for details (of which there aren't many).


mbxcvt

To copy or move messages, converting the format, use 'mbxcvt'. It transfers messages from the source to a new mailbox in the specified format. This is probably not needed, as its functionality (in most cases) is duplicated by mbxcopy. 'man mbxcvt' for more info.

Personal tools