archivemail is a tool for archiving and compressing old email in mailboxes\&. By default it will read the mailbox
\fIMAILBOX\fR, moving messages that are older that the specified number of days (180 by default) to a
\fBmbox\fR(5)\-format mailbox in the same directory that is compressed with
\fBgzip\fR(1)\&. It can also just delete old email rather than archive it\&.
.PP
By default,
\fBarchivemail\fR
derives the archive filename from the mailbox name by appending an
_archive
suffix to the mailbox name\&. For example, if you run
\fBarchivemail\fR
on a mailbox called
exsouthrock, the archive will be created with the filename
exsouthrock_archive\&.gz\&. This default behavior can be overridden with command line options, choosing a custom suffix, a prefix, or a completely custom name for the archive\&.
Messages that are flagged important are not archived or deleted unless explicitly requested with the
\fB\-\-include\-flagged\fR
option\&. Also,
\fBarchivemail\fR
can be configured not to archive unread mail, or to only archive messages larger than a specified size\&.
.PP
To archive an
IMAP\-format mailbox, use the format
\fIimap://username:password@server/mailbox \fR
to specify the mailbox\&.
archivemail
will expand wildcards in
IMAP
mailbox names according to
RFC
3501, which says:
\(lq The character "*" is a wildcard, and matches zero or more characters at this position\&. The character "%" is similar to "*", but it does not match a hierarchy delimiter\&.\(rq
You can omit the password from the
URL; use the
\fB\-\-pwfile\fR
option to make
\fBarchivemail\fR
read the password from a file, or alternatively just enter it upon request\&. If the
\fB\-\-pwfile\fR
option is set,
\fBarchivemail\fR
does not look for a password in the
URL, and the colon is not considered a delimiter\&. Substitute \*(Aq\fBimap\fR\*(Aq with \*(Aq\fBimaps\fR\*(Aq, and
can be a date string in ISO format (eg \*(Aq2002\-04\-23\*(Aq), Internet format (eg \*(Aq23 Apr 2002\*(Aq) or Internet format with full month names (eg \*(Aq23 April 2002\*(Aq)\&. Two\-digit years are not supported\&. This option is incompatible with the
to create the filename used for archives\&. The default is
_archive, unless a prefix is specified\&.
.sp
Like a prefix, the suffix
\fINAME\fR
is expanded by the
\fBpython\fR(1)
function
time\&.strftime()
with the archive cut\-off date\&.
time\&.strftime()
understands the following directives:
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%a\fR
Locale\*(Aqs abbreviated weekday name\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%A\fR
Locale\*(Aqs full weekday name\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%b\fR
Locale\*(Aqs abbreviated month name\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%B\fR
Locale\*(Aqs full month name\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%c\fR
Locale\*(Aqs appropriate date and time representation\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%d\fR
Day of the month as a decimal number [01,31]\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%H\fR
Hour (24\-hour clock) as a decimal number [00,23]\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%I\fR
Hour (12\-hour clock) as a decimal number [01,12]\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%j\fR
Day of the year as a decimal number [001,366]\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%m\fR
Month as a decimal number [01,12]\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%M\fR
Minute as a decimal number [00,59]\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%p\fR
Locale\*(Aqs equivalent of either AM or PM\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%S\fR
Second as a decimal number [00,61]\&. (1)
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%U\fR
Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]\&. All days in a new year preceding the first Sunday are considered to be in week 0\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%w\fR
Weekday as a decimal number [0(Sunday),6]\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%W\fR
Week number of the year (Monday as the first day of the week) as a decimal number [00,53]\&. All days in a new year preceding the first Sunday are considered to be in week 0\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%x\fR
Locale\*(Aqs appropriate date representation\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%X\fR
Locale\*(Aqs appropriate time representation\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%y\fR
Year without century as a decimal number [00,99]\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%Y\fR
Year with century as a decimal number\&.
.RE
.sp
.RS4
.ien\{\
\h'-04'\(bu\h'+03'\c
.\}
.el\{\
.sp-1
.IP\(bu2.3
.\}
\fB%Z\fR
Time zone name (or by no characters if no time zone exists)\&.
Don\*(Aqt write to any files \-\- just show what would have been done\&. This is useful for testing to see how many messages would have been archived\&.
.RE
.PP
\fB\-u, \-\-preserve\-unread\fR
.RS4
Do not archive any messages that have not yet been read\&.
\fBarchivemail\fR
determines if a message in a
mbox\-format or
MH\-format mailbox has been read by looking at the
Status
header (if it exists)\&. If the status header is equal to \*(AqRO\*(Aq or \*(AqOR\*(Aq then
archivemail
assumes the message has been read\&.
\fBarchivemail\fR
determines if a
maildir
message has been read by looking at the filename\&. If the filename contains an \*(AqS\*(Aq after
:2,
then it assumes the message has been read\&.
.RE
.PP
\fB\-\-dont\-mangle\fR
.RS4
Do not mangle lines in message bodies beginning with "From "\&. When archiving a message from a mailbox not in
mbox
format, by default
\fBarchivemail\fR
mangles such lines by prepending a \*(Aq>\*(Aq to them, since mail user agents might otherwise interpret these lines as message separators\&. Messages from
mbox
folders are never mangled\&. See
\fBmbox\fR(5)
for more information\&.
.RE
.PP
\fB\-\-delete\fR
.RS4
Delete rather than archive old mail\&. Use this option with caution!
.RE
.PP
\fB\-\-copy\fR
.RS4
Copy rather than archive old mail\&. Creates an archive, but the archived messages are not deleted from the originating mailbox, which is left unchanged\&. This is a complement to the
\fB\-\-delete\fR
option, and mainly useful for testing purposes\&. Note that multiple passes will create duplicates, since messages are blindly appended to an existing archive\&.
.RE
.PP
\fB\-\-all\fR
.RS4
Archive all messages, without distinction\&.
.RE
.PP
\fB\-\-include\-flagged\fR
.RS4
Normally messages that are flagged important are not archived or deleted\&. If you specify this option, these messages can be archived or deleted just like any other message\&.
.RE
.PP
\fB\-\-no\-compress\fR
.RS4
Do not compress any archives\&.
.RE
.PP
\fB\-\-warn\-duplicate\fR
.RS4
Warn about duplicate
Message\-IDs that appear in the input mailbox\&.
.RE
.PP
\fB\-v, \-\-verbose\fR
.RS4
Reports lots of extra debugging information about what is going on\&.
.RE
.PP
\fB\-\-debug\-imap=\fR\fB\fINUM\fR\fR
.RS4
Set
IMAP
debugging level\&. This makes
\fBarchivemail\fR
dump its conversation with the
IMAP
server and some internal
IMAP
processing to
stdout\&. Higher values for
\fINUM\fR
give more elaborate output\&. Set
\fINUM\fR
to 4 to see all exchanged
IMAP
commands\&. (Actually,
\fINUM\fR
is just passed literally to
imaplib\&.Debug\&.)
.RE
.PP
\fB\-q, \-\-quiet\fR
.RS4
Turns on quiet mode\&. Do not print any statistics about how many messages were archived\&. This should be used if you are running
\fBarchivemail\fR
from cron\&.
.RE
.PP
\fB\-V, \-\-version\fR
.RS4
Display the version of
\fBarchivemail\fR
and exit\&.
.RE
.PP
\fB\-h, \-\-help\fR
.RS4
Display brief summary information about how to run
will strip the dots off the archive name, so that the resulting archive file is not hidden\&. This is not done if the
\fB\-\-prefix\fR
or
\fB\-\-archive\-name\fR
option is used\&. Should there really be mailboxes distinguished only by leading dots in the name, they will thus be archived to the same archive file by default\&.
of email addresses in mind\&. So, rather than enforcing an
URL\-style encoding of non\-ascii
and reserved characters, it allows to double\-quote the username and password\&. If your username or password contains the delimiter characters \*(Aq@\*(Aq or \*(Aq:\*(Aq, just quote it like this:
\fIimap://"username@bogus\&.com":"password"@imap\&.bogus\&.com/mailbox \fR\&. You can use a backslash to escape double\-quotes that are part of a quoted username or password\&. Note that quoting only a substring will not work, and be aware that your shell will probably remove unprotected quotes or backslashes\&.
If an IMAP mailbox path contains slashes, the archive filename will be derived from the basename of the mailbox\&. If the server\*(Aqs folder separator differs from the Unix slash and is used in the IMAP URL, however, the whole path will be considered the basename of the mailbox\&. E\&.g\&. the two URLs \fBimap://user@example\&.com/folder/subfolder\fR and \fBimap://user@example\&.com/folder\&.subfolder\fR will be archived in subfolder_archive\&.gz and folder\&.subfolder_archive\&.gz, respectively, although they might refer to the same IMAP mailbox\&.
.sp
\fBarchivemail\fR does not support reading MMDF or Babyl\-format mailboxes\&. In fact, it will probably think it is reading an mbox\-format mailbox and cause all sorts of problems\&.
.sp
\fBarchivemail\fR is still too slow, but if you are running from \fBcrontab\fR(5) you won\*(Aqt care\&. Archiving maildir\-format mailboxes should be a lot quicker than mbox\-format mailboxes since it is less painful for the original mailbox to be reconstructed after selective message removal\&.