1ARCHIVEMAIL(1) ARCHIVEMAIL(1)
2
3
4
6 archivemail - archive and compress your old email
7
9 archivemail [ options ] MAILBOX ...
10
11
13 archivemail is a tool for archiving and compressing old email in mail‐
14 boxes. By default it will read the mailbox MAILBOX, moving messages
15 that are older that the specified number of days (180 by default) to a
16 mbox(5)-format mailbox in the same directory that is compressed with
17 gzip(1). It can also just delete old email rather than archive it.
18
19 archivemail supports reading IMAP, Maildir, MH and mbox-format mail‐
20 boxes, but always writes mbox-format archives.
21
22 Messages that are flagged important are not archived or deleted unless
23 explicitely requested with the --include-flagged option. Also,
24 archivemail can be configured not to archive unread mail, or to only
25 archive messages larger than a specified size.
26
27 To archive an IMAP-format mailbox, use the format imap://username:pass‐
28 word@server/mailbox to specify the mailbox. You can omit the password
29 from the URL; use the --pwfile option to make archivemail read the
30 password from a file, or alternatively just enter it upon request. If
31 the --pwfile option is set, archivemail does not look for a password in
32 the URL, and the colon is not considered a delimiter. Substitute
33 'imap' with 'imaps', and archivemail will establish a secure SSL con‐
34 nection. See below for more IMAP peculiarities.
35
36 archivemail has some support for being run as the root user on user
37 mailboxes. When running as root, it will seteuid(2) to the owner of the
38 mailbox it is reading, creating any archive files as that user. Warn‐
39 ing: this automatic seteuid feature is insecure and deprecated. It
40 will be removed from later versions of archivemail.
41
43 -d NUM, --days=NUM
44 Archive messages older than NUM days. The default is 180. This
45 option is incompatible with the --date option below.
46
47 -D DATE, --date=DATE
48 Archive messages older than DATE. DATE can be a date string in
49 ISO format (eg '2002-04-23'), Internet format (eg '23 Apr 2002')
50 or Internet format with full month names (eg '23 April 2002').
51 Two-digit years are not supported. This option is incompatible
52 with the --days option above.
53
54 -o PATH, --output-dir=PATH
55 Use the directory name PATH to store the mailbox archives. The
56 default is the same directory as the mailbox to be read.
57
58 -P FILE, --pwfile=FILE
59 Read IMAP password from file FILE instead of from the command
60 line. Note that this will probably not work if you are archiv‐
61 ing folders from more than one IMAP account.
62
63 -F STRING, --filter-append=STRING
64 Append STRING to the IMAP filter string. For IMAP wizards.
65
66 -s NAME, --suffix=NAME
67 Use the suffix NAME to create the filename used for archives.
68 The default is _archive. For example, if you run archivemail on
69 a mailbox called exsouthrock, the archive will be created with
70 the filename exsouthrock_archive.gz.
71
72 NAME is run through the python(1) time.strftime() function,
73 which means that you can specify any of the following special
74 directives in NAME to make archives named after the archive cut-
75 off date:
76
77 · %a Locale's abbreviated weekday name.
78
79 · %A Locale's full weekday name.
80
81 · %b Locale's abbreviated month name.
82
83 · %B Locale's full month name.
84
85 · %c Locale's appropriate date and time representation.
86
87 · %d Day of the month as a decimal number [01,31].
88
89 · %H Hour (24-hour clock) as a decimal number [00,23].
90
91 · %I Hour (12-hour clock) as a decimal number [01,12].
92
93 · %j Day of the year as a decimal number [001,366].
94
95 · %m Month as a decimal number [01,12].
96
97 · %M Minute as a decimal number [00,59].
98
99 · %p Locale's equivalent of either AM or PM.
100
101 · %S Second as a decimal number [00,61]. (1)
102
103 · %U Week number of the year (Sunday as the first day of the
104 week) as a decimal number [00,53]. All days in a new year pre‐
105 ceding the first Sunday are considered to be in week 0.
106
107 · %w Weekday as a decimal number [0(Sunday),6].
108
109 · %W Week number of the year (Monday as the first day of the
110 week) as a decimal number [00,53]. All days in a new year pre‐
111 ceding the first Sunday are considered to be in week 0.
112
113 · %x Locale's appropriate date representation.
114
115 · %X Locale's appropriate time representation.
116
117 · %y Year without century as a decimal number [00,99].
118
119 · %Y Year with century as a decimal number.
120
121 · %Z Time zone name (or by no characters if no time zone
122 exists).
123
124 · %% A literal "%" character.
125
126 -S NUM, --size=NUM
127 Only archive messages that are NUM bytes or greater.
128
129 -n, --dry-run
130 Don't write to any files -- just show what would have been done.
131 This is useful for testing to see how many messages would have
132 been archived.
133
134 -u, --preserve-unread
135 Do not archive any messages that have not yet been read.
136 archivemail determines if a message in a mbox-format or MH-for‐
137 mat mailbox has been read by looking at the Status header (if it
138 exists). If the status header is equal to 'RO' or 'OR' then
139 archivemail assumes the message has been read. archivemail
140 determines if a maildir message has been read by looking at the
141 filename. If the filename contains an 'S' after :2, then it
142 assumes the message has been read.
143
144 --dont-mangle
145 Do not mangle lines in message bodies beginning with "From ".
146 When archiving a message from a mailbox not in mbox format, by
147 default archivemail mangles such lines by prepending a '>' to
148 them, since mail user agents might otherwise interpret these
149 lines as message separators. Messages from mbox folders are
150 never mangled. See mbox(5) for more information.
151
152 --delete
153 Delete rather than archive old mail. Use this option with cau‐
154 tion!
155
156 --copy
157 Copy rather than archive old mail. Creates an archive, but the
158 archived messages are not deleted from the originating mailbox,
159 which is left unchanged. This is a complement to the --delete
160 option, and mainly useful for testing purposes.
161
162 --include-flagged
163 Normally messages that are flagged important are not archived or
164 deleted. If you specify this option, these messages can be
165 archived or deleted just like any other message.
166
167 --no-compress
168 Do not compress any archives.
169
170 --warn-duplicate
171 Warn about duplicate Message-IDs that appear in the input mail‐
172 box.
173
174 -v, --verbose
175 Reports lots of extra debugging information about what is going
176 on.
177
178 -q, --quiet
179 Turns on quiet mode. Do not print any statistics about how many
180 messages were archived. This should be used if you are running
181 archivemail from cron.
182
183 -V, --version
184 Display the version of archivemail and exit.
185
186 -h, --help
187 Display brief summary information about how to run archivemail.
188
190 archivemail requires python(1) version 2.3 or later. When reading an
191 mbox-format mailbox, archivemail will create a lockfile with the exten‐
192 sion .lock so that procmail will not deliver to the mailbox while it is
193 being processed. It will also create an advisory lock on the mailbox
194 using flock(2). archivemail will also complain and abort if a 3rd-
195 party modifies the mailbox while it is being read.
196
197 archivemail will always attempt to preserve the mode, last-access and
198 last-modify times of the input mailbox. However, archive mailboxes are
199 always created with a mode of 0600. If archivemail finds a pre-exist‐
200 ing archive mailbox it will append rather than overwrite that archive.
201 archivemail will refuse to operate on mailboxes that are symbolic links
202 or create tempfiles or archives in world-writable directories.
203
204 archivemail attempts to find the delivery date of a message by looking
205 for valid dates in the following headers, in order of precedence:
206 Delivery-date, Date and Resent-Date. If it cannot find any valid date
207 in these headers, it will use the last-modified file timestamp on MH
208 and Maildir format mailboxes, or the date on the From line on mbox-for‐
209 mat mailboxes.
210
211 A conversion from other formats to mbox(5) will silently overwrite
212 existing Status and X-Status message headers.
213
214 IMAP
215 When archivemail processes an IMAP folder, all messages in that folder
216 will have their \Recent flag unset, and they will probably not show up
217 as 'new' in your user agent later on. There is no way around this,
218 it's just how IMAP works. This does not apply, however, if you run
219 archivemail with the options --dry-run or --copy.
220
221 archivemail relies on server-side searches to determine the messages
222 that should be archived. When matching message dates, IMAP servers
223 refer to server internal message dates, and these may differ from both
224 delivery time of a message and its Date header. Also, there exist bro‐
225 ken servers which do not implement server side searches.
226
227 IMAP URLS
228 archivemail's IMAP URL parser was written with the RFC 2882 (Internet
229 Message Format) rules for the local-part of email addresses in mind.
230 So, rather than enforcing an URL-style encoding of non-ascii and
231 reserved characters, it allows to double-quote the username and pass‐
232 word. If your username or password contains the delimiter characters
233 '@' or ':', just quote it like this: imap://"username@bogus.com":"pass‐
234 word"@imap.bogus.com/mailbox. You can use a backslash to escape dou‐
235 ble-quotes that are part of a quoted username or password. Note that
236 quoting only a substring will not work, and be aware that your shell
237 will probably remove unprotected quotes or backslashes.
238
239 IMAP servers supporting subfolders may use any character as a mailbox
240 path separator, that is, as an equivalent to the slash character on
241 Unix systems. If you are archiving an IMAP subfolder, first archive‐
242 mail will try to open a given mailbox name unchanged; if this fails, it
243 will interpret any slashes in the URL as path separators and try again.
244
246 To archive all messages in the mailbox debian-user that are older than
247 180 days to a compressed mailbox called debian-user_archive.gz in the
248 current directory:
249
250 bash$ archivemail debian-user
251
252 To archive all messages in the mailbox debian-user that are older than
253 180 days to a compressed mailbox called debian-user_October_2001.gz
254 (where the current month and year is April, 2002) in the current direc‐
255 tory:
256
257 bash$ archivemail --suffix '_%B_%Y' debian-user
258
259 To archive all messages in the mailbox cm-melb that are older than the
260 first of January 2002 to a compressed mailbox called cm-melb_archive.gz
261 in the current directory:
262
263 bash$ archivemail --date'1 Jan 2002' cm-melb
264
265 Exactly the same as the above example, using an ISO date format
266 instead:
267
268 bash$ archivemail --date=2002-01-01 cm-melb
269
270 To delete all messages in the mailbox spam that are older than 30 days:
271
272 bash$ archivemail --delete --days=30 spam
273
274 To archive all read messages in the mailbox incoming that are older
275 than 180 days to a compressed mailbox called incoming_archive.gz in the
276 current directory:
277
278 bash$ archivemail --preserve-unread incoming
279
280 To archive all messages in the mailbox received that are older than 180
281 days to an uncompressed mailbox called received_archive in the current
282 directory:
283
284 bash$ archivemail --no-compress received
285
286 To archive all mailboxes in the directory $HOME/Mail that are older
287 than 90 days to compressed mailboxes in the $HOME/Mail/Archive direc‐
288 tory:
289
290 bash$ archivemail -d90 -o $HOME/Mail/Archive $HOME/Mail/*
291
292 To archive all mails older than 180 days from the given IMAP INBOX to a
293 compressed mailbox INBOX_archive.gz in the $HOME/Mail/Archive direc‐
294 tory, quoting the password and reading it from the environment variable
295 PASSWORD:
296
297 bash$ archivemail -o $HOME/Mail/Archive imaps://user:'"'$PASSWORD'"'@example.org/INBOX
298
299 Note the protected quotes.
300
302 Probably the best way to run archivemail is from your crontab(5) file,
303 using the --quiet option. Don't forget to try the --dry-run and per‐
304 haps the --copy option for non-destructive testing.
305
307 Normally the exit status is 0. Nonzero indicates an unexpected error.
308
310 If an IMAP mailbox path contains slashes, the archive filename will be
311 derived from the basename of the mailbox. If the server's folder sepa‐
312 rator differs from the Unix slash and is used in the IMAP URL, however,
313 the whole path will be considered the basename of the mailbox. E.g.
314 the two URLs imap://user@example.com/folder/subfolder and
315 imap://user@example.com/folder.subfolder will be archived in sub‐
316 folder_archive.gz and folder.subfolder_archive.gz, respectively,
317 although they might refer to the same IMAP mailbox.
318
319 archivemail does not support reading MMDF or Babyl-format mailboxes. In
320 fact, it will probably think it is reading an mbox-format mailbox and
321 cause all sorts of problems.
322
323 archivemail is still too slow, but if you are running from crontab(5)
324 you won't care. Archiving maildir-format mailboxes should be a lot
325 quicker than mbox-format mailboxes since it is less painful for the
326 original mailbox to be reconstructed after selective message removal.
327
329 python(1), gzip(1), mutt(1), procmail(1)
330
332 The archivemail home page is currently hosted at sourceforge
333 <URL:http://archivemail.sourceforge.net>
334
336 This manual page was written by Paul Rodger <paul at paulrodger dot
337 com>. Updated and supplemented by Nikolaus Schulz <microschulz@web.de>
338
339
340
341SP 07 November 2007 ARCHIVEMAIL(1)