mailtool — Process mailboxes
mailtool is a diagnostic utility for handling various operations on mailboxes. mailtool's main uses include: display the list of folders in a mailbox; displaying list of messages in a mailbox; and copying mailboxes.
The following mailboxes can be accessed by mailtool:
An IMAP account. mailtool will prompt for the login password.
An IMAP account accessed via an encrypted SSL connection.
A POP3 account. mailtool will prompt for the login password.
A POP3 account accessed via an encrypted SSL connection.
A local maildir mailbox.
path specifies the maildir's location
relative to the home directory (NOT the current
Local mbox mail folders.
path specifies the path to an mbox
folder file, or a directory containing mbox folders,
relative to the home directory (NOT the current
Local mbox mail folders, like “mbox:
additionally, the system spool mailbox is automatically
which is accessible as folder
The name of a remote IMAP or POP3 server may be followed by one or more options that control various settings of the IMAP or POP3 connection:
Do not open the account unless the server supports
secure password authentication. Secure password
authentication verifies the account's password using a
challenge/response authentication mechanism (where the
cram" comes from).
The actual password is never actually transmitted to
the server, and therefore cannot be intercepted while
in transit over an untrusted network.
Secure password authentication is not supported by
all servers. This option may not work with some
servers. This option does not enable secure password
authentication, it only mandates its use. If the server
supports secure password authentication, it will be
used even without the
/cram option. Traditional
userid/password authentication will be used only if the
server does not implement secure password
option makes secure password authentication
/cram option is
marginally useful even with encrypted server
connections. The secure password authentication never
sends the explicit password to the server. Encryption
makes it theoretically impossible to recover the
password from an encrypted data connection; but with
secure authentication the password is never sent over
the connection in the first place (the password's
validity is certified by exchanging certain
mathematical calculations between the server and the
client). If the server is compromised, the compromised
server will not receive the account password (unless
the password is recovered from the server in other
Do not use the SMAP if the server claims the
availability of this experimental mail access protocol,
and fall back to IMAP compatibility mode (this option
is meaningful only with “
Do not upgrade a plain connection to an encrypted one. This option is primarily used for testing and debugging purposes. Sometimes this option might be useful with servers that claim to offer encryption, but are unable to do so when taken up on their offer.
Do not validate the server's SSL certificate when using an encrypted connection. Normally the mail server's SSL certificate must be validate when using an encrypted connection. The certificate's name must match the server's name, and the certificate must be signed by a trusted certificate authority.
The encrypted connection normally fails if the certificate cannot be validate. Validation requires that a list of trusted certificate authorities must be known and configured. It's simply impossible to know which certificate authorities are valid without an explicit list of valid, known, trusted, certificate authorities. If a trusted authority list is not configured, no certificate can be validated. If the server's certificate is a self-signed certificate (this is often used for testing purposes), or if it's not signed by a known authority, the encrypted connection fails.
option disables certificate validation. The encrypted
connection will be established even if the server's
certificate would otherwise be rejected.
This option is applicable even when an encrypted IMAP or POP3 connection is not explicitly requested. Many mail servers are capable of automatically upgrading unencrypted connections to a fully-encrypted connection. If a mail server claims to be able to use encryption, then there's no reason not to use it. The result is that all encryption certification requirements still apply even when encryption is not explicitly requested.
mailtool -tree | -list
-tree shows a hierarchical
representation of mail folders in
-list generates a simple folder listing,
one folder name per line.
-tree shows folder names, while
-list shows the actual mail
folder path in
mailtool -tree imap://firstname.lastname@example.org/novalidate-cert/cram
mailtool -create |
-create creates a new
account. The new
subfolder's name is
-createdir creates a new folder directory
(a folder that contains other folders).
mailtool -create INBOX.lists announcements maildir:Maildir
This command creates a new folder “announcements” as a subfolders of “INBOX.lists” in the local maildir.
mailtool -delete |
-delete deletes an existing
-deletedir deletes a folder
mailtool -delete INBOX.lists.announcements maildir:Maildir
-renames renames an
oldfolder. The folder is
as a subfolder of
folder may be an empty
string if the folder should be moved to the top level of
mailtool -rename INBOX.lists.announcements INBOX.lists Announcements maildir:Maildir
The folder “INBOX.lists.announcements” is
renamed to “INBOX.lists.Announcements”.
This slightly unusual way to rename folder allows folders
to be relocated in the mail
-index downloads and prints
a summary of all messages in
account. The summary shows
the sender's and recipients' address, the message's
subject, and size.
mailtool -index INBOX imap://email@example.com/novalidate-cert
-remove removes message
n (ranging from
1 to the number of messages in the folder) in
account. The message
numbers may be obtained by using
n may be a
comma-separated list of message numbers, in strictly
numerically increasing order.
-remove confirms the list of messages to
remove and issues a “Ready:” prompt. Press
remove the messages.
mailtool -remove INBOX 28,31 imap://firstname.lastname@example.org/novalidate-cert
-filter is a combination of
folder's index is
downloaded, and the summary of each message is shown, one
message at a time. Each message's summary is followed by a
prompt: “Delete, Skip, or Exit”.
removes the message, S leaves the message
unchanged, and E leaves the remaining
mailtool -filter INBOX pop3://email@example.com/novalidate-cert
-filter is not meant to
be used with large folders. Unless messages are removed
quickly, the connection to the server may be disconnected
This command copies an entire folder,
fromaccount to a new folder,
tofolder (which will be created, if
that all subfolders of
fromfolder should also be copied.
mailtool -tofolder INBOX -copyto maildir:Maildir \ -fromfolder "INBOX" imap://firstname.lastname@example.org/novalidate-cert mailtool -recurse -tofolder INBOX.converted_mail \ -copyto maildir:Maildir -fromfolder "mail" \ imap://email@example.com/novalidate-cert
This example first copies the INBOX on the IMAP server
$HOME/Maildir, then copies
subfolders of “mail” on the IMAP server to the
“converted_mail” subfolder in
mailtool -tofolder INBOX -copyto maildir:Maildir \ -fromfolder "INBOX" inbox:mail mailtool -recurse -tofolder INBOX.converted_mail \ -copyto maildir:Maildir -fromfolder "" mbox:mail
This example first copies
$HOME/Inbox (accessed as the INBOX folder
in inbox:mail) to
$HOME/Maildir, then copies mbox folders
$HOME/mail to the
“converted_mail” subfolder in
Mail accounts that contain hybrid folders (folders that contain both messages and subfolders) can only be copied to account types that also support hybrid folders: either local maildirs, or to remote servers that support hybrid folders.