Compare commits

...

317 Commits

Author SHA1 Message Date
Nikolaus Schulz e1a6028332 test suite: bail out on python versions << 2.4
The test suite uses function that were introduced in Python 2.4 (e.g.
set(), sorted()).
2012-11-04 23:29:08 +01:00
Nikolaus Schulz 4346bc5815 manpage: minor grammar fix "allows to" -> "allows you to"
This error was found by lintian.
2011-07-10 00:18:05 +02:00
Nikolaus Schulz e3f0440305 MANIFEST: distribute db2man.xsl 2011-07-09 20:32:29 +02:00
Nikolaus Schulz 22d4393cb6 Bump year in copyright notes 2011-07-09 19:58:36 +02:00
Nikolaus Schulz 09e460555e Prepare release of archivemail v0.9.0 2011-07-09 19:17:21 +02:00
Nikolaus Schulz 87084b69f0 NEWS: note support for international IMAP mailbox names 2011-07-09 19:15:57 +02:00
Nikolaus Schulz e3f5289e13 Changelog: shorten message about fix for test suite failures with Python 2.7
That really were too much details nobody cares for.
2011-07-09 19:11:43 +02:00
Nikolaus Schulz 483a58879f test suite: adapt to new behaviour of parse_imap_url()
This also removes some pretty bogus test URLs.
2011-07-09 19:03:16 +02:00
Nikolaus Schulz 1fa57aa577 Manpage: update last-modified date 2011-07-09 18:42:36 +02:00
Nikolaus Schulz 6cb9ba9122 FAQ: update note about missing bzip2 support 2011-07-09 18:41:20 +02:00
Nikolaus Schulz 14e0929ba2 Changelog: record improved handling of empty IMAP SEARCH response 2011-07-09 18:17:13 +02:00
Nikolaus Schulz 14e5cd6eb1 test suite: add simple test for parsing IMAP urls specifying port numbers 2011-07-09 18:03:40 +02:00
Nikolaus Schulz eb07611fae IMAP: support servers listening on non-standard ports 2011-07-09 18:03:12 +02:00
Nikolaus Schulz f9f9eacd88 IMAP: handle broken servers sending no untagged SEARCH response
The proprietary "SmartMail" IMAP server likes to send no untagged SEARCH
response when the set of matching email messages is empty.

This was brought up as sf.net support request #3213272.
2011-07-09 16:53:19 +02:00
Nikolaus Schulz 947be25f82 Fix whitespace and formatting of the manpage XML source 2011-07-05 23:45:34 +02:00
Nikolaus Schulz 88653766db Manpage & changelog: document support for international IMAP mailbox names 2011-07-05 23:45:34 +02:00
Nikolaus Schulz 6b0fefc45f IMAP: add support for non-ascii mailbox names 2011-07-05 23:45:28 +02:00
Nikolaus Schulz f6046b9d69 test suite: let FixedGzipFile.seek() pass on what gzip.GzipFile.seek() returned
This fixes test suite failures with Python 2.7.

Starting with Python 2.7, gzip.GzipFile is subclassing io.IOBase.
The seek() method of io.IOBase differs from file.seek() and the old
gzip.GzipFile.seek() in that it returns the new file position, not None.

And in Python 2.7, gzip.GzipFile.tell() is inherited from
io.IOBase.tell(), which is implemented using its seek() method.
FixedGzipFile subclasses gzip.GzipFile and overrides seek(); therefore,
this method need be adapted for this change in the interface.

Closes: #3314293.
2011-06-18 00:13:41 +02:00
Nikolaus Schulz 39e6a532d0 Makefile: remove obsolete rules
* docbook2{man,html} used to generate temporary files; the new XML tool
  xsltproc does not, so we can drop the corresponding cleanup rule.
* The `bdist_rpm' rule for building rpm packages was broken for a long
  time, and therefore commented out.  The distutils bug that broke the
  rule is now fixed, but I'm removing the rule nevertheless because it's
  useless.
* The `upload' rule no longer works; drop it.
* Update .PHONY
2011-03-28 23:55:22 +02:00
Nikolaus Schulz 8173caa81d Add .gitignore, ignoring auto-generated files 2011-03-28 23:29:51 +02:00
Nikolaus Schulz 4f8171341d Update changelog 2011-03-28 23:17:50 +02:00
Nikolaus Schulz 0e1aace796 Manpage & webpage CSS: drop font selections
There's no need to tell the visitor which fonts to use; she knows best
what she likes, so let her decide.
2011-03-28 23:07:03 +02:00
Nikolaus Schulz 8190e4807e Manpage: lots of cleanup and fixes in the XML and formatting 2011-03-28 23:06:07 +02:00
Nikolaus Schulz 0437ec3e8b Remove manpage, there is no need to keep an auto-generated file around 2011-03-28 22:58:59 +02:00
Nikolaus Schulz c2106bdda1 manpage: define proper "manual" and "source" strings 2011-01-07 08:58:40 +01:00
Nikolaus Schulz f6be896b1f Port man page from SGML to XML 2010-12-29 02:49:08 +01:00
Nikolaus Schulz ea0d95e121 IMAP: don't collect statistics data when run with --quiet option
This gives a significant operation speedup in quiet mode.
2010-12-26 15:18:36 +01:00
Nikolaus Schulz 7ee2555cc2 Fix typo in the manpage 2010-12-26 14:49:18 +01:00
Nikolaus Schulz 393f08bb2e setup.py: install manpage into share/man/man1 instead of man/man1
This change aims to comply with the FHS, which puts manpages into
/usr/share/man, not /usr/man.
2010-11-28 02:02:51 +01:00
Nikolaus Schulz ad4c4b9642 Default options.debug_imap to 0 again, not False
This was overdone when switching from integers to booleans.
Here 0 and False are in fact probably equivalent, but it's still a bug.
2010-11-12 21:38:32 +01:00
Nikolaus Schulz a08cde18fb Update changelog and prepare 0.8.2 release 2010-10-16 18:58:04 +02:00
Nikolaus Schulz 77a2856e48 IMAP: don't prepend NAMESPACE prefix to INBOX and its children 2010-10-16 18:57:43 +02:00
Nikolaus Schulz 45f82b7218 Update changelog and prepare 0.8.1 release 2010-09-30 22:12:30 +02:00
Nikolaus Schulz eb8bc7a4ec IMAP: correctly handle IMAP `literal' and unquoted `astring' in LIST reply
The LIST reply handling in imap_find_mailboxes() was buggy in several
ways.  It expected a non-NIL hierarchy delimiter, and it assumed that the
mailbox name in a LIST reply is always quoted; but it can be an astring, a
quoted string, or a literal (see RFC 3501 for the definitions of these
tokens).  These variants should now all be interpreted correctly.

In addition, quoted mailbox names are now handled more strictly to the
letter of the RFC; this only affects mailbox names containing a " or a
backslash, though.
2010-09-26 21:28:54 +02:00
Nikolaus Schulz b7091e90ea Releasing 0.8.0: fix release date in the changelog, and update the project web page 2010-08-09 13:25:41 +02:00
Nikolaus Schulz 945c4bb28e MANIFEST.in: distribute NEWS 2010-08-09 13:16:14 +02:00
Nikolaus Schulz 40a5e6a9f9 Add new file NEWS, gathering noteworthy changes from the changelog 2010-08-09 13:14:23 +02:00
Nikolaus Schulz 5d5408dcd2 Remove release notes
This file is not really suitable to put into a revision control system.
2010-08-09 13:12:13 +02:00
Nikolaus Schulz 5fb60dd522 Regenerate manpage from sgml source 2010-08-09 11:43:30 +02:00
Nikolaus Schulz 8d01846e3f Manpage, TODO, CHANGELOG: document and record wildcard expansion in IMAP mailbox names 2010-08-09 11:43:10 +02:00
Nikolaus Schulz f08403c99b Expand wildcards in IMAP mailbox names
The only non-obvious code change required for this is due to the fact that
computing the archive names has to move into the format-specific archiving
functions, because they can no longer be derived from the mailbox name
beforehand.
2010-08-09 11:32:01 +02:00
Nikolaus Schulz 910b507a2d TODO: drop more obsolete items
In particular:
* we no longer use shutil.copy{,2} to write back a changed mbox
* having temporary mbox files in the same directory as the originals doesn't
  make sense anymore since we no longer commit them with rename(2)
* the --archive-name option is now implemented
2010-08-08 18:53:11 +02:00
Nikolaus Schulz ca80e185e6 Regenerate manpage from sgml source 2010-07-31 22:08:22 +02:00
Nikolaus Schulz 3a6e4072b0 Manpage: various updates
Document the --archive-name option, and explain the basic idea of deriving the
archive filename from the mailbox earlier and more prominently.  Also document
how archivemail tries not to create hidden archive files, and remove some
obsolete notes.
2010-07-31 22:05:11 +02:00
Nikolaus Schulz 3a9a5cd4b8 New option --archive-name, alias -a, to hard-code the archive filename 2010-07-31 20:49:30 +02:00
Nikolaus Schulz 04bf8eaa23 test suite: fix buggy test of --suffix and --prefix option parsing 2010-07-31 20:49:30 +02:00
Nikolaus Schulz 0921a1c91a test suite: replace some plain assertions with TestCase.assertEqual() 2010-07-31 20:49:30 +02:00
Nikolaus Schulz 40ba265fde Rename variables in make_archive_name()
Archive name prefixes may contain path components, thus renaming some
variables accordingly.
2010-07-31 20:49:29 +02:00
Nikolaus Schulz f1f34ca46e Don't create hidden archives when archiving mailboxes with leading dots in the name
When archiving a mailbox with leading dots in the name and no archive name
prefix specified, strip the dots off the archive name.  This is targeting
Maildir++ subfolders.
2010-07-31 20:49:29 +02:00
Nikolaus Schulz 67f23e1af4 Only use the default archive name suffix when the user specified no affix
Also add more archive name affix testing to the test suite.
2010-07-31 20:49:29 +02:00
Nikolaus Schulz b6bc92c34f New option --archive-prefix, alias -p
Technically, this works just like the --suffix option.  This commit also
updates the manpage accordingly.

Currently, the prefix is not checked for slashes, so it could contain path
components.  (The same applies for the suffix, btw).  Since the expanded
string is prepended to the archive base name, this can be used to dynamically
configure the archive directory, depending on the archive cutoff date.  I'm
not sure if this can be considered a reasonable feature, though.
2010-07-31 20:49:03 +02:00
Nikolaus Schulz f22fe4decd Detect and never archive IMAP server pseudo mbox messages
IMAP servers (Dovecot and UW-IMAP at least) may store mailbox meta data for
mboxes in a pseudo message.  Such messages are now detected and never archived.

This commit includes a test case in the test suite.
2010-07-30 19:15:21 +02:00
Nikolaus Schulz d99b4b4414 Give the changelog some more love
Add references to bug numbers and be more verbose.
2010-07-30 15:42:26 +02:00
Nikolaus Schulz e9446e2fc4 test suite: test unlocking an mbox after dotlocking failed with EACCES 2010-07-30 13:30:20 +02:00
Nikolaus Schulz eadedf27d0 Fix crash when unlocking an mbox after dotlocking failed with EACCES
If we don't have sufficient permissions to create a dotlock for an mbox file,
record that, and don't try to remove the dotlock when unlocking the mbox
later.
2010-07-30 13:24:36 +02:00
Nikolaus Schulz 71485f2469 index.html: reword pointer to the Suse Build Service to be more generic
Better don't write "soon there will be... <foo>" and don't be specific about
available versions.  Writing it more generically means lesser maintenance. :)
2010-07-30 12:29:18 +02:00
Nikolaus Schulz db8eb62c16 Regenerate manpage from the sgml source 2010-07-30 12:29:14 +02:00
Nikolaus Schulz 6813e21d54 Updated the manpage date 2010-07-30 12:25:56 +02:00
Nikolaus Schulz 1c412524f2 Document in the manpage that archivemail locks the archive mbox 2010-07-30 12:25:55 +02:00
Nikolaus Schulz 03932a8cb2 Remove the notes about setuid support from the manpage
This feature has been removed.
2010-07-29 22:55:00 +02:00
Nikolaus Schulz 280113982f Replace distutils MANIFEST with MANIFEST.in template
Recent distutils versions always generate a new MANIFEST, overwriting our
custom one.  See Python bug #8688.
2010-07-29 22:12:52 +02:00
Nikolaus Schulz a102b5baf9 Rename archivemail.py to archivemail
On Unix, most scripts don't come with a file extension, it's not needed, and
we distribute the script as "archivemail" anyway.  And most importantly, I
like it better without the extension. :)

With a little trick we can still load the script as a module from the test
suite.
2010-07-29 21:35:58 +02:00
Nikolaus Schulz b47cc46fbf README: drop warning that the test suite is slow
With the recent optimizations of the test suite, it has become quite fast.
2010-07-29 21:32:37 +02:00
Nikolaus Schulz febd030e14 Drop .py extension from the unittest script 2010-07-29 21:02:12 +02:00
Nikolaus Schulz a04226580b Bump version to 0.8.0 2010-07-29 21:02:07 +02:00
Nikolaus Schulz 89cff1807c Updated changelog, which was very outdated 2010-07-29 20:39:50 +02:00
Nikolaus Schulz 0eddfe7357 Updated copyright year 2010-07-29 20:39:46 +02:00
Nikolaus Schulz af3bb16a4c Updated TODO, dropping a lot of obsolete items
Notable items that are now resolved or implemented:
    * archives are now locked
    * the mbox classes have been refactored to a cleaner design
    * we moved from flock locking to fcntl
    * the setuid() feature is long gone
    * symlink attacks for tempfiles are not possible (that is really an
      ancient TODO item from the original author)
    * the test suite now has a lot of maildir test cases
2010-07-29 19:49:42 +02:00
Nikolaus Schulz 368f312e2d test suite: add more maildir test cases
Maildir testing should now be roughly on par with mbox testing.
2010-07-29 19:29:53 +02:00
Nikolaus Schulz 2ce89ef508 test suite: remove unused remove() methods from maildir classes
For cleanup of temporary files, we lean on shutil.rmtree anyway, so don't
bother wasting more code on this.
2010-07-29 15:46:15 +02:00
Nikolaus Schulz 7058290c2e test suite: remove incomplete MH testing code
I just discovered that archivemails MH support is broken with respect to
message flags, and in my opinion it doesn't make much sense to test
known-broken functionality.

In fact there may well be zero archivemail users with MH mailboxes; MH is
basically an obsolete format, and any archivemail user with MH mailboxes would
probably have complained about lost message flags.
2010-07-29 15:46:15 +02:00
Nikolaus Schulz 0dfae37e04 test suite: first shot at implementing maildir test cases 2010-07-29 15:46:10 +02:00
Nikolaus Schulz 78c4c6e3da test suite: remove obsolete $Id$ subversion keyword 2010-07-29 14:41:05 +02:00
Nikolaus Schulz d845ab862e test suite: cleanup of the mbox testing code
This code is complex, too complex actually.  Rename some methods and
variables, rework some code and and add some explaining comments in order to
make it it least a bit easier to understand.
2010-07-29 14:41:00 +02:00
Nikolaus Schulz 584918b265 test suite: remove obsolete test that we preserve mbox file modes
This test case is obsolete since we no longer replace the mbox file with a new
copy but rewrite it.
2010-07-29 13:32:20 +02:00
Nikolaus Schulz 9ff7774aba Fix TempMbox.saveas() to unregister the right file from _stale 2010-07-28 15:28:39 +02:00
Nikolaus Schulz e5ee9b98c1 Python language fix: replace C-style boolean values "1" and "0" with True/False 2010-07-19 01:40:25 +02:00
Nikolaus Schulz 7269c32734 Remove unused variable 2010-07-19 01:40:25 +02:00
Nikolaus Schulz 80b3483439 Python language fix: remove parentheses around asserted expressions
assert is not a function.
2010-07-19 01:40:25 +02:00
Nikolaus Schulz 2d15728c2d Add a note about the race window when resetting an mbox file timestamp 2010-07-19 01:40:25 +02:00
Nikolaus Schulz dcf849afeb TODO: new items: make IMAP test suite with no network I/O; drop .py extension 2010-07-19 01:40:25 +02:00
Nikolaus Schulz 573f2b9358 Warn if the temporary directory is not empty on cleanup 2010-07-19 01:40:25 +02:00
Nikolaus Schulz 4fb833176e When creating a dotlock, register it slightly earlier for cleanup
This closes a very unlikely window where we could create a dotlock file, but
then encounter an error and fail to clean up the dotlock.
2010-07-19 01:40:25 +02:00
Nikolaus Schulz 2b7baaf294 In verbose mode, say that we're about to dotlock an mbox before trying to do so 2010-07-19 01:40:25 +02:00
Nikolaus Schulz 0f2b04ff89 Minor docstring/whitespace fixes 2010-07-19 01:40:25 +02:00
Nikolaus Schulz b9b2174c45 At critical points, flush mbox files and sync them to disk
This should minimize the risk of data loss.  Flushing a locked mbox file
before unlocking it also ensures that there's no window when another
process could lock the mbox after us, but still see the old content.
2010-07-19 01:40:24 +02:00
Nikolaus Schulz 86471d12a4 Further refactoring of the mbox classes, adding archive locking support
The mbox locking methods move into a new class LockableMboxMixin, and the
Mbox and ArchiveMbox classes become subclasses of LockableMboxMixin.
class StaleFiles is updated to handle multiple dotlock files.
2010-07-19 01:40:24 +02:00
Nikolaus Schulz da595427ff Fail as gracefully as possible if writing out the new mailboxes fails
In particular:

* If writing the archived messages to the final archive fails, try to
  restore the archive and abort (by not handling the exception).  This is
  possible since we first save the archive, and only then the modified
  mailbox, so we don't corrupt the original mbox in this case.
* If writing a modified mbox file fails, save the temporary copy.
2010-07-19 01:40:24 +02:00
Nikolaus Schulz 1db28f2b04 Refactoring of the mbox classes
The RetainMbox and ArchiveMbox classes are now gone, mainly because their
finalise() methods were messing with the archived mbox and the archive,
respectively, which was not good OO design.

The core functionality of the finalise() methods of both removed classes
is moved to the objects that are manipulated: the Mbox class representing
the mbox that is being archived gains a new method overwrite_with(), and
there is a new class ArchiveMbox that represents the actual archive, which
has an append() method (yes, unfortunately the new class has the same name
like the removed class).

The RetainMbox instance is replaced with a TempMbox, and the ArchiveMbox
instance either with a TempMbox, or a CompressedTempMbox if archive
compression is enabled.

Finally, a compressed TempMbox is now a implemented as a subclass of
TempMbox, named CompressedMbox.

Cooperation with the StaleFiles class moves into the TempMbox class.
This means slightly less detailed verbose cleanup reporting, oh well.
2010-07-19 01:40:24 +02:00
Nikolaus Schulz 40f9a4c049 Use safe methods to open the archive mbox and an existing mbox file 2010-07-19 01:17:02 +02:00
Nikolaus Schulz f031573071 mbox locking: omit dotlock if we don't have the permissions to create it
Closes: issue #855269.
2010-07-19 01:13:25 +02:00
Nikolaus Schulz 11103e2de2 mbox locking: combine locking functions into one and swap lock order
We used to create a dotlock file first and then lock with fcntl; swap that
order, since locking first with fcntl seems to be more common.

This patch also adds general mbox lock/unlock methods, which call the
dotlock and fcntl-lock methods, and moves the retry logic there.

When the dotlock and fcntl methods fail to acquire a lock, they now raise
a custom exception "LockUnavailable", which gets caught in the general
lock() method.  That way, if we succeed to acquire one lock but fail to
acquire the other, we can release our locks at the upper level and retry.
2010-07-19 01:13:25 +02:00
Nikolaus Schulz d706409c59 Switch mbox locking from flock(2) to posix lockf(2)
flock() locks aren't portable; lockf() locks are.
2010-07-19 01:13:25 +02:00
Nikolaus Schulz d726589414 Rename procmail_lock->dotlock_lock
An entirely cosmetic variable rename, but it's just not correct to call
this a "procmail lock".  Also reword some comments accordingly.
2010-07-19 01:13:25 +02:00
Nikolaus Schulz c6e462fef0 test suite: use common base class with helper methods for mbox testing
These helper methods provide success verification after test archiving runs, and
test case setup.  This is a tradeoff: because these methods need to support all
scenarios in one place, they introduce some new complexity - but they replace a
lot of tedious, very similar, but still not entirely identical code all over the
place.
2010-07-19 01:13:25 +02:00
Nikolaus Schulz 84f42ead36 test suite: cut down the test of the --all option
Don't do entire test archiving runs, just call
archivemail.should_archive().
2010-07-19 01:13:25 +02:00
Nikolaus Schulz 512130df02 test suite: cut down the test of the --preserve-unread option
Don't do entire test archiving runs, just call
archivemail.should_archive().
2010-07-19 01:13:25 +02:00
Nikolaus Schulz 03bfb88d30 test suite: change misleading test case name
TestArchiveMboxPreserveStatus actually doesn't test that the message
status is preserved, but that the --preserve-unread option works.
Rename it to TestArchiveMboxPreserveUnread.
2010-07-19 01:13:25 +02:00
Nikolaus Schulz 41da26b655 test suite: cut down the test of the --size option
Don't do entire test archiving runs, just call
archivemail.should_archive().
2010-07-19 01:13:25 +02:00
Nikolaus Schulz 6d2e23ac80 test suite: cut down the test of --output-dir
Don't do entire test archiving runs, just call
archivemail.make_archive_name() and verify the result.
2010-07-19 01:13:25 +02:00
Nikolaus Schulz 8ec8a00ffa test suite: cut down testing the handling of flagged messages
Don't do entire test archiving runs, just call
archivemail.should_archive().
2010-07-19 01:13:25 +02:00
Nikolaus Schulz 0ca3f6ceee test suite: remove duplicate test case for --date option 2010-07-19 01:13:25 +02:00
Nikolaus Schulz bf99c6b69d test suite: cut down archive suffix generation testing
Don't do entire test archiving runs, just call
archivemail.make_archive_name() and verify the result.
2010-07-19 01:13:24 +02:00
Nikolaus Schulz 232b2256c2 test suite: test weird message headers in one run
Before, every test header was tested in a separate archiving run.
2010-07-19 01:13:24 +02:00
Nikolaus Schulz 573cbbce91 test suite: cut down the test of date header processing
Don't do entire test archiving runs, just call
archivemail.should_archive().
2010-07-19 01:13:24 +02:00
Nikolaus Schulz e9d2284a07 test suite: let make_message() optionally return a rfc822.Message 2010-07-19 01:13:24 +02:00
Nikolaus Schulz 8476dcd18f Remove lots of redundant test runs from the test suite
The test suite used to run a lot of triple tests, by first calling
archivemail.archive() directly, and then running the entire archivemail
script twice, once with long and once with short options.  But we already
test option processing seperately, and beyond that, archivemail.main()
essentially just calls archive() for each mailbox in turn.  So we just drop
all runs of the entire archivemail script from the test suite, giving it a
huge speed boost (on my old iBook, running the test suite drops from 73 to
5 seconds).
2010-07-19 01:13:24 +02:00
Nikolaus Schulz 8f58deef5c Test suite: test command line option processing 2010-07-19 01:13:24 +02:00
Nikolaus Schulz f80e709f7e test suite: eliminate remaining call of external gzip program
Use gzip.GzipFile instead.
2010-07-19 01:13:24 +02:00
Nikolaus Schulz 8c6f4b99c1 test suite: define and use assertEqualContent() to compare files
This eliminates a lot of copy-and-paste code, and switches from
os.system("gzip <...>") to gzip.GzipFile.
2010-07-19 01:13:24 +02:00
Nikolaus Schulz 9d9f13a440 test suite: account for lacking precision of os.utime()
os.utime() uses the utimes(2) system call to set file timestamps.  utimes(2)
has a microsecond resolution, but stat(2) may return timestamps with
nanosecond resolution.  So, the check that we have properly reset the mbox
file timestamp must allow a minor deviation.
2010-07-19 01:13:24 +02:00
Nikolaus Schulz 54821151e4 Fix minor race when deleting messages in a maildir/mh box
Nothing serious, but if another client deleted it in the small window after
we checked it, we would have crashed trying to delete a non-existing file.
2010-07-19 01:13:24 +02:00
Nikolaus Schulz a7414319c9 Simplify the final committing of the mailbox and archive
* Make the finalise() methods spot if they have anything to do
* We used to create the temporary mbox files on demand in the message
  processing loop, if we needed to write to them.  Now we create them
  beforehand, but only if they might be needed (e.g. we don't create an
  archive if options.delete_old_mail is set).
* The above combined makes the final committing of the changes simpler (a
  *lot* simpler for mboxes), and we can dump the Mbox.leave_empty() method.
2010-07-19 01:13:24 +02:00
Nikolaus Schulz b37b3d627e Split out new class TempMbox
This separates write-only mbox access to the temporary mboxes from the read-only
access to the original mbox.
2010-07-19 01:01:04 +02:00
Nikolaus Schulz d6a161cd9e Simplify ArchiveMbox.__init__ 2009-11-06 21:09:40 +01:00
Nikolaus Schulz df680c19be Append to the archive, and don't use rename()
This is WIP to prepare locking for the archive.  Since we no longer copy the
whole archive before appending, archiving should also be faster.
2009-11-06 21:09:40 +01:00
Nikolaus Schulz 37f96c1c84 Remove unused method Mbox.is_empty() 2009-11-06 21:09:40 +01:00
Nikolaus Schulz a78af4c0ff Keep mbox files open, so we don't break our locks
When committing a changed mbox, don't use os.rename(), and don't open/close
the mbox file to truncate it to zero length.  Locking was pretty much broken
before -- at least in theory a quite severe bug.
2009-11-06 21:09:39 +01:00
Nikolaus Schulz ba8928d279 Cleanup restoring of the mbox timestamps
* Remove code duplication: restore the mbox timestamps once and for all when
  we're done
* Don't bother restoring the file mode when finishing, since this is handled in
  RetainMbox.finalise() (and need be)
* Therefore, rename Mbox.reset_stat() to reset_timestamps()
2009-11-06 21:09:39 +01:00
Nikolaus Schulz 223e2f9802 Cosmetics: in verbose mode, report current mailbox early
This is now before we do the sanity checking, so in verbose mode, we don't error
out before having said that we now turn attention to the current mailbox.
2009-11-06 21:09:39 +01:00
Nikolaus Schulz aee4df2fcf Refuse to process mailboxes owned by someone else
This should also protect people relying on the old setuid feature.
If the mailbox is local, by checking the ownership we necessarily check for
existance.
2009-11-06 21:09:39 +01:00
Nikolaus Schulz 2e0f3cd3aa Sanity check existing archives early
This used to happen when creating the temporary archive, we now do it before we
start processing the mailbox.
2009-11-06 21:09:39 +01:00
Nikolaus Schulz 79bcf86860 Remove simple-minded security checks
Remove the checks if the mailbox is a symlink, and if the output directory is
world-writable.  Better no security than half-baked security.
2009-11-06 21:09:39 +01:00
Nikolaus Schulz a3276f8c68 Move archive naming code into new function make_archive_name() 2009-11-06 21:09:38 +01:00
Nikolaus Schulz cd07a2663e Remove the setuid functionality
It was not a good idea, and trying to do it right would be too much effort.
2009-11-06 21:09:38 +01:00
Nikolaus Schulz bd85cffe37 Simplify imap_get_namespace() and imap_guess_mailboxnames()
I don't think anybody wants to archive folders in shared or public IMAP
namespaces, so we don't bother checking all possible namespaces.  The code was
ugly anyway.
2009-11-06 21:09:38 +01:00
Nikolaus Schulz 9574c4f41c Removed obsolete references to subversion
archivemail development has moved to git.  This patch updates the project
webpage, removes the subversion $Id$ keyword that was stored in
archivemail.__svn_id__, and updates the Makefile.
2009-11-06 17:20:16 +01:00
Nikolaus Schulz c6cb0b4612 IMAP: imap_guess_mailboxnames: check for NIL delimiter.
Only replace the slash with the server's hierarchy delimiter if the latter
actually exists (is not NIL).
2008-04-09 00:22:07 +00:00
Nikolaus Schulz 415e055a6e TODO: dropped items about --all, which is now implemented. 2008-04-08 23:15:45 +00:00
Nikolaus Schulz 622c0105ea IMAP: only check for \Deleted in PERMANENTFLAGS if mailbox isn't read-only.
This spewed an error when --dry-running.
2008-04-08 23:06:10 +00:00
Nikolaus Schulz 775952ec98 IMAP: added sanity check for \Deleted in PERMANENTFLAGS. 2008-04-08 19:31:11 +00:00
Nikolaus Schulz 681fd0c527 Minor, local variable renaming. 2008-04-08 19:10:41 +00:00
Nikolaus Schulz e5b6397dd5 Moved IMAP SELECT code into a separate function. 2008-04-08 19:06:42 +00:00
Nikolaus Schulz 78b4923832 IMAP: be NAMESPACE-aware; improved probing for guessed mailbox names.
* Automatically add NAMESPACE prefix to the mailbox path if necessary, 
  * Explicitely check for guessed mailbox names with LIST instead of just trying
    to SELECT them. 
  * Updated documentation about NAMESPACE handling.
2008-04-08 15:38:51 +00:00
Nikolaus Schulz 37816fd659 archivemail.sgml: warn that multiple passes with --copy will create duplicates. 2008-04-08 14:11:45 +00:00
Nikolaus Schulz bfff00e395 Code structuring: made a separate group of IMAP functions.
No code changes, just moved functions around.
2008-04-07 20:16:29 +00:00
Nikolaus Schulz 07219ff14b IMAP: servers should never advertise LOGINDISABLED with SSL; removed the check
for it, which was just used to spit a special error message anyway.
2008-03-21 01:05:15 +00:00
Nikolaus Schulz 26ab4611ec Archiving an IMAP folder with --all didn't archive *any* messages.
The message sequence numbers must be strings, but were generated as integers;
fixed.
2008-03-19 18:30:43 +00:00
Nikolaus Schulz efe02ea32a Updated year in another copyright note, which I overlooked before. 2008-03-16 17:57:18 +00:00
Nikolaus Schulz bc5c3d5e45 Updated changelog, which was a little behind. 2008-03-15 20:51:40 +00:00
Nikolaus Schulz a9215463c4 Removed an assertion which choked upon --days=0. 2008-03-15 20:34:52 +00:00
Nikolaus Schulz f43cbb106d Added new option --all to archive all messages in a mailbox.
Updated documentation, and added a first simple unittest for this.
Closes: #1764846.
2008-03-15 20:24:46 +00:00
Nikolaus Schulz 2719645f2c Updated copyright notes to include year 2008. 2008-03-15 19:39:28 +00:00
Nikolaus Schulz 9ac3a68228 Documented the new option --debug-imap in the manpage. 2008-03-15 19:35:22 +00:00
Nikolaus Schulz c0f0ad33d7 Fixed crash when archiving an empty maildir with python 2.5.
The incompatible changes in mailbox.Maildir triggered an assertion in
_archive_dir(); removing that assertion since it looks not useful anyway.
2008-03-15 18:42:56 +00:00
Nikolaus Schulz 22e23d9d38 Sanitized parsing some IMAP server responses by switching to regular
expressions.
2008-03-15 15:59:05 +00:00
Nikolaus Schulz f6f7903f58 test_archivemail.py: removed nested calls to setUp() and tearDown(). 2008-03-06 20:09:44 +00:00
Nikolaus Schulz afa61f8597 TODO: added items:
* perhaps integrate --debug-imap into -vv switch
* graceful IMAP connection termination upon error
2008-02-14 22:31:11 +00:00
Nikolaus Schulz 704d5a961e Added --debug-imap option which just sets imaplib.Debug. 2008-02-14 22:26:10 +00:00
Nikolaus Schulz 6abf732d2e IMAP: catch LOGINDISABLED, and suggest using imaps. 2008-02-14 22:24:16 +00:00
Nikolaus Schulz 533628c2fc Only try CRAM-MD5 authentication if the server advertises it. 2008-02-14 22:19:34 +00:00
Nikolaus Schulz 1fcd5b7292 TODO: added issues:
- no locking with archives
- no validation of existing archives
- discomfort with current mbox class design and usage
2008-01-19 00:12:35 +00:00
Nikolaus Schulz 77481169d8 _archive_imap() used SSL only if the 'imaps://' url scheme was all lowercase.
Fixed.
2008-01-19 00:04:01 +00:00
Nikolaus Schulz ce02aba226 Updated TODO list. Added:
* rework locking
 * IMAP SEARCH BEFORE matching dates only, no time
 * document mbox format issues
2007-11-15 04:15:25 +00:00
Nikolaus Schulz 8e5c870057 guess_delivery_time():
* look for the timestamp of the latest 'Received' header before resorting to
   'Date' or 'Resent-Date'.  
 * let 'Resent-date' header take precedence over 'Date'. 
Document these changes in manpage and changelog. 
Closes: #1481316, #1764855, Debian bug #272666.
2007-11-13 21:13:38 +00:00
Nikolaus Schulz 4584dffe14 Fixed date header parsing to be precise with timezone information. Also, when
writing From_ line timestamps, don't use UTC but local time, without timezone
information.
2007-11-13 02:59:31 +00:00
Nikolaus Schulz 5178c956bc !%&$*# Repair previous broken commit where an unrelated hunk slipped through.
Reverted that hunk.
2007-11-13 00:36:51 +00:00
Nikolaus Schulz d9ffaf4a3b When converting from other formats to mbox, re-use existing 'Status' and
'X-Status' headers if appropriate (instead of deleting and re-generating them).
2007-11-13 00:32:49 +00:00
Nikolaus Schulz ead112daba If running as root, only call seteuid/setegid if the if the owner of the mailbox
is not root.
2007-11-09 17:04:52 +00:00
Nikolaus Schulz 0ae7edab86 Bumped version to 0.7.2, and updated release info on the webpage. 2007-11-09 14:54:54 +00:00
Nikolaus Schulz 8cc36126ec RELNOTES: slightly re-edited to be more consistent. 2007-11-09 14:52:38 +00:00
Nikolaus Schulz f1784f3093 RELNOTES, CHANGELOG: updated for v0.7.2, which fixes a crash with IMAP and
python << 2.5.
2007-11-09 14:46:17 +00:00
Nikolaus Schulz e0c75a1001 IMAP: fixed crash by working around python bug #1277098, which is still pending
in python << 2.5.
2007-11-09 14:33:13 +00:00
Nikolaus Schulz 5db3d2fe63 Makefile: made the htdocs rule a little bit more intelligent. 2007-11-08 18:23:15 +00:00
Nikolaus Schulz c19a9873b0 Makefile: declare phony targets. 2007-11-08 18:09:45 +00:00
Nikolaus Schulz 796f60f8c8 Makefile: added rule to generate htdocs tarball. 2007-11-07 23:59:45 +00:00
Nikolaus Schulz c4841fe4cd CHANGELOG: added entry about IMAP delimiter detection and recovery. 2007-11-07 23:58:48 +00:00
Nikolaus Schulz 4b64da911e Debug message improvements. Explicitely say if we're selecting an IMAP mailbox
read-only.  Improve some formatting.
2007-11-07 23:57:03 +00:00
Nikolaus Schulz adf6515746 Added more debugging messages to the IMAP flag conversion. 2007-11-07 23:51:41 +00:00
Nikolaus Schulz 9439e1fa8a Minor code cleanup. 2007-11-07 23:50:18 +00:00
Nikolaus Schulz 11ebc2e011 New release notes for v0.7.1. 2007-11-07 22:33:04 +00:00
Nikolaus Schulz 5b72c8287c Updated and edited manpage:
* drop prominent note about being a python program; 
* extended description a bit;
* Document issue with slashes in IMAP mailbox paths.
2007-11-07 22:32:07 +00:00
Nikolaus Schulz d5cb3dad61 IMAP: if selecting a mailbox fails with both the original path name and with
replaced path delimiters, report failure for the original path.
2007-11-07 21:10:08 +00:00
Nikolaus Schulz 8596d68092 TODO: update for the upcoming release. Added new item:
* fix possible wrong names for IMAP mailbox archives
2007-11-07 19:59:18 +00:00
Nikolaus Schulz f47de26676 Minor code cleanups. 2007-11-07 19:52:52 +00:00
Nikolaus Schulz fbb00e08f4 IMAP: if selecting the mailbox fails, then detect the server's mailbox hierarchy
delimiter, replace slashes in the mailbox name with the delimiter and try again.
2007-11-07 16:31:49 +00:00
Nikolaus Schulz 1e5cb090e7 Fixed IMAP --verbose mode to say what we're *intending* to do next, instead of
reporting success after the fact.  This makes a lot more sense for debugging. 
Also added some more messages.
2007-11-07 14:33:17 +00:00
Nikolaus Schulz bcb01613d0 archivemail.py, setup.py, test_archivemail.py:
bumped version to 0.7.1, and updated copyright.
2007-11-07 00:57:44 +00:00
Nikolaus Schulz d57987be04 TODO: new items:
* implement --all (?)
* implement --include-draft (?)
* consider to use target directories for temporary files, this might spare us
  one copy if they reside on other filesystems than /tmp
* fallback if an IMAP server doesn't implement SEARCH (?)
2007-11-06 23:54:50 +00:00
Nikolaus Schulz 2d608bffe7 Makefile: run HTML tidy on the autogenerated HTML manpage. This spews quite
some errors and exits with nonzero, but the result is still very useful, and I
managed to tranquilize tidy. :-)
2007-11-06 23:49:47 +00:00
Nikolaus Schulz 5f929f6697 Makefile: added note that python/distutils bug #644744 prevents using the
bdist_rpm target.
2007-11-06 23:45:21 +00:00
Nikolaus Schulz 54fbaf5844 manpage.css, style.css:
* moved some rules from the first to the latter, and @import the latter for the
  manpage. 
* added some further formatting for index.html.
2007-11-06 23:38:05 +00:00
Nikolaus Schulz 61d0e803c6 db2html.dsl: override $refentry-body$ from dbrfntry.dsl to add a <hr> after the
refentry title <h1>.
2007-11-06 23:33:33 +00:00
Nikolaus Schulz 372b45d7b0 index.html: major overhaul: re-edited and partly rewritten.
Some notably changes: 
* don't make so much noise about archivemail being a python program; 
* add little box with current version information; 
* partly reworded for a more friendly, inviting tone (hopefully); 
* removed some superfluous links to trivial information like the pyhon.org
  website; 
* link changelog and TODO file to HEAD in the svn browser instead of using
  (obsolete) copies; 
* warmly encourage svn access; 
* drop dead link to article about archivemail.
2007-11-06 23:24:48 +00:00
Nikolaus Schulz 75e3ae94a9 index.html: fixed to be valid HTML 4 strict. 2007-11-06 02:50:15 +00:00
Nikolaus Schulz 373695a64d index.html: finally committed the updated download link to the Opensuse build
service.  (This version is online since 2006-11-03.)
2007-11-05 21:24:59 +00:00
Nikolaus Schulz 204893eeab index.html: removed obsolete note that the testsuite requires Python >= 2.1. 2006-11-03 03:49:07 +00:00
Nikolaus Schulz 5abff64e5a Added new file RELNOTES (release notes for v0.7.0) and linked to it in
index.html.
2006-11-03 00:36:00 +00:00
Nikolaus Schulz 4bbc0216ef index.html: added maintainer email addresses.
(Left out Brandon because he's not active.)
2006-11-03 00:22:18 +00:00
Nikolaus Schulz b10c66aa35 index.html: synced with README and updated for v0.7.0. 2006-11-03 00:11:29 +00:00
Nikolaus Schulz 9e8649cb92 For what it's worth, I've committed the htdocs state before the release of
v0.7.0.  The htdocs were not imported in svn, and the latest changes there not
committed to cvs.  Oh well, for now I'll use the RCS that's there (cvs).
2006-11-02 22:06:49 +00:00
Brandon Knitter ab0f6dbf98 index.html: added in some maintainer comments, as well as the current release
section
2003-10-29 03:12:49 +00:00
Brandon Knitter fe773d4822 index.html, style.css: initial import. 2003-10-29 03:03:43 +00:00
Nikolaus Schulz 3fd26dcb45 Files added:
db2html.dsl (DSSSL stylesheet)
    manpage.css (HTML stylesheet)
Updated Makefile to let docbook2html use db2html.dsl.
2007-11-04 22:13:59 +00:00
Nikolaus Schulz f582fd75c9 archivemail.sgml: wrap examples in <informalexample>. 2007-11-03 00:51:23 +00:00
Nikolaus Schulz 3f5f591728 archivemail.sgml: edited and reordered 'Notes' section so that it looks nicer. 2007-11-03 00:24:37 +00:00
Nikolaus Schulz be4aabc20f archivemail.sgml: document that the conversion from other formats to mbox
overwrites existing 'Status' and 'X-Status' messages headers.
2007-11-02 23:46:17 +00:00
Nikolaus Schulz 74c871644e When converting from other formats to mbox, don't preserve existing 'Status' and
'X-Status' mbox headers, we better overwrite them with correct values.
2007-11-02 23:35:50 +00:00
Nikolaus Schulz c0552fcd06 With IMAP no IdentityCache object was initialized, causing a crash if
--warn-duplicates was used.  Closes: Debian bug #434786.
2007-11-02 21:53:20 +00:00
Nikolaus Schulz 3e0288e21b TODO: removed obsolete items:
- documentation of IMAP server side search peculiarities
    - Debian bug #255944, which has been recorded as unreproducible, and fixed
      in rev. 186.
2007-11-02 21:26:12 +00:00
Nikolaus Schulz b40da3124a archivemail.py: added --copy option to the usage message. 2007-11-02 21:21:17 +00:00
Nikolaus Schulz aae08fe3fb Let archivemail accept --days=0. 2007-11-02 21:18:23 +00:00
Nikolaus Schulz 59e9715021 Expand tilde in argument of long option --pwfile. 2007-11-02 21:06:59 +00:00
Nikolaus Schulz e25367fcb8 Documented the new --copy option in the manpage. 2007-11-02 20:50:30 +00:00
Nikolaus Schulz c5002cdefb Updated manpage: note that IMAP server internal message dates may differ from
user-visible date headers, and that there exist servers not supporting searches.
2007-11-02 20:42:16 +00:00
Nikolaus Schulz c97b10f253 Hm, forgot the autogenerated manpage in the previous commit. 2007-11-02 20:27:37 +00:00
Nikolaus Schulz b2f94206b1 Deprecate the old automatic seteuid feature; document this in the manpage and
changelog, and let archivemail spit a warning when it changes the effective user
id.
2007-11-02 20:26:40 +00:00
Nikolaus Schulz dfec62850e Updated manpage: document that archivemail will implicitly unset the \Recent
message flag of all messages in an IMAP folder.
2007-11-02 19:21:10 +00:00
Nikolaus Schulz 3ee105d766 If running as root, only switch the effective uid and gid back if we have
actually switched them before.
2007-11-02 18:47:23 +00:00
Nikolaus Schulz a1641450ed Added simple unittest for the --copy option. Mbox only. :-/ 2007-11-02 18:21:21 +00:00
Nikolaus Schulz bcb00dbbed CHANGELOG: updated to cover fixed IMAP message flag handling and new --copy
option.
2007-11-02 17:53:29 +00:00
Nikolaus Schulz 3240b24d9f New option --copy: archive mail, but don't delete it from the mailbox.
Closes: #981865, #988803, #1764851, Debian bug #434798
2007-11-02 17:44:38 +00:00
Nikolaus Schulz 0eba452d93 IMAP: first fetch message flags, then the body. Doing it together always
returns the \Seen flag set.  
Closes: Debian bug #434807 (well, the outstanding part of it).
2007-11-02 13:21:18 +00:00
Nikolaus Schulz 130a5ef117 When converting from maildir or IMAP to mbox, report existing 'Status' and
'X-Status' headers in verbose mode, since they are preserved, which can give
surprising results.
2007-11-02 12:27:32 +00:00
Nikolaus Schulz 82e3be1987 IMAP: fixed message flags retrieval, which failed to extract the right string
from the server response.  Tough.
2007-11-02 12:00:12 +00:00
Nikolaus Schulz 6ea7c7d810 If dry-running, open IMAP mailboxes read-only. This uses EXAMINE instead of
select, thus preserving the \Recent flag.
2007-11-02 11:44:21 +00:00
Nikolaus Schulz 9e70e576af add_status_headers_imap():
* mark message 'old' iff it's not \Recent (drop requirement that it's
      unread; this probably confused mutt's message status flags in the index
      with mbox status flags). 
    * a message not \Seen and not \Recent was marked as 'N', but there is no
      such thing like an mbox status flag 'N'.
2007-11-02 11:26:20 +00:00
Nikolaus Schulz 1d89f59b53 TODO: drop paragraph about reworking the IMAP URL parser (done). 2007-11-01 12:01:44 +00:00
Nikolaus Schulz 6d2d1fba44 Changelog: updated latest entry: added credit to Elan Ruusamäe for tracking
#1783369 down, and made it more verbose about the related Debian bugs.
2007-11-01 11:55:12 +00:00
Nikolaus Schulz 9b7768e073 Rewrote and reordered parts of the manpage:
* Move paragraph about archiving IMAP folders before the option list
    * Added section subsection about IMAP URL handling
    * Added IMAP example command line
2007-10-24 14:58:47 +00:00
Nikolaus Schulz d566d6c8f3 Makefile: updated SVNROOT variable. 2007-10-24 11:30:00 +00:00
Nikolaus Schulz b40728e740 Updated changelog about latest bugfix (skipping invalid files in Maildirs). 2007-10-24 02:33:31 +00:00
Nikolaus Schulz 8e73e315e4 Skip invalid messages/files in Maildirs.
Closes: #1783369, Debian bug #255944, and Debian bug #305902 also seems about
        this issue.
2007-10-24 02:23:59 +00:00
Nikolaus Schulz b07a4cfbf3 TODO: new items:
* IMAP unittests
    * bug triage
    * Porting to email.message and the new mailbox modules in python 2.5.
2007-10-23 23:29:05 +00:00
Nikolaus Schulz 256492039a Added unittest for the new IMAP URL parser. 2007-10-23 23:23:44 +00:00
Nikolaus Schulz f3719df4d2 Updated documentation WRT to the new quoted usernames/passwords in IMAP URLs. 2007-10-23 23:11:29 +00:00
Nikolaus Schulz 0e9ae1d91b New IMAP URL parser that understands double-quoted usernames and passwords.
Closes: #1640878
2007-10-23 22:48:15 +00:00
Nikolaus Schulz 1493a22f38 Define very simple exception classes, mapping to the error functions
user_error() and unexpected_error().  If archivemail is used as a module, let
the functions raise the corresponding exceptions rather than writing to stderr
and calling sys.exit().
2007-10-23 22:27:57 +00:00
Nikolaus Schulz 255a475978 Use a wrapper around rfc822.Message.fp to find the filename for Maildir/MH
emails.  Python 2.5 broke backward compatibility for Maildirs. :-/
Closes: #1670422
2007-10-22 22:03:44 +00:00
Nikolaus Schulz c67a75c2f7 TODO: updated with some old items which weren't yet committed to svn. 2007-09-18 00:30:10 +00:00
Nikolaus Schulz 8abd70093f Expand tilde in argument of long option --output-dir, the shell doesn't. 2006-11-14 22:20:37 +00:00
Nikolaus Schulz ef97390118 Corrected python dependency in the man page. 2006-11-06 21:41:59 +00:00
Nikolaus Schulz 32ecf02025 README: Updated python dependency, removed note about the required zlib module
since that should be pretty much standard, and added maintainer email addresses.
2006-11-02 23:04:14 +00:00
Nikolaus Schulz faa68b2048 Bumped version to 0.7.0 2006-11-02 06:43:09 +00:00
Nikolaus Schulz 8de4715e5c Renamed __cvs_id__ to __svn_id__. 2006-11-02 06:40:31 +00:00
Nikolaus Schulz 58f67ff286 Changelog update: added IMAP error reporting 2006-11-02 05:49:18 +00:00
Nikolaus Schulz 0278901ba1 Added a note to the manpage that --pwfile will not work if archiving folders
from several IMAP accounts.
2006-11-02 05:45:26 +00:00
Nikolaus Schulz cb48d392fa TODO update. Added: IMAP url clutter/password leakage, unfriendly locking
practice.  Removed: only prompt for IMAP password when running in terminal.
2006-11-02 05:43:33 +00:00
Nikolaus Schulz 46f9aa44a9 Split the final stats message in two lines, because it might otherwise linewrap. 2006-11-02 05:36:17 +00:00
Nikolaus Schulz 810dea1bf5 Made IMAP password prompt a tad bit more verbose. 2006-11-01 21:05:10 +00:00
Nikolaus Schulz 3d8a1bda89 Don't prompt for the IMAP password if in quiet mode or if not running
interactively (stdin is not a terminal).
2006-11-01 20:57:58 +00:00
Nikolaus Schulz 89e6683334 Improved IMAP error handling: pass error messages from the server on to the
user, and check if deleting the messages was successful.
2006-11-01 20:35:53 +00:00
Nikolaus Schulz c7d074abde Streamlined verbose IMAP messages a bit. 2006-11-01 20:25:09 +00:00
Nikolaus Schulz d79da0ae99 Removed redundant check if imap login was succesful, since IMAP4.login then
raises an exception.
2006-11-01 20:23:44 +00:00
Nikolaus Schulz c5f194f3ec Tightened some blanket exception handlers. 2006-11-01 19:49:47 +00:00
Nikolaus Schulz e872f2211e Changed misleading references to 'message ids' in the IMAP code to the
technically correct 'message sequence number'.
2006-11-01 06:11:55 +00:00
Nikolaus Schulz bea6ef6390 Optimized IMAP code: just invert the message list from the SEARCH response
instead of querying the server another time with an inverted search filter.
Gather RFC822.SIZE in one big run.
2006-11-01 05:27:30 +00:00
Nikolaus Schulz 86f1fec50d Renamed variable 'filter' to prevent conflicts with the builtin function. 2006-11-01 00:40:26 +00:00
Nikolaus Schulz e9a11944f1 Updated CHANGELOG and polished it a bit for the upcoming release. 2006-10-31 05:00:15 +00:00
Nikolaus Schulz 7a2e1b7c69 Added a few items to the TODO list that won't be resolved with the next release. 2006-10-31 04:50:05 +00:00
Nikolaus Schulz f9965b8e23 Reverted script name change from rev. 101, so we generate a clean tarball again. 2006-10-31 04:47:24 +00:00
Nikolaus Schulz b3dc8a006e Always sanity-check each archive destination directory, not only when it's
specified with --output-dir.
2006-10-31 04:09:31 +00:00
Nikolaus Schulz dcd37f6466 Make stats report size totals for the mailboxes and the archived messages, and
while at it, make stats work with IMAP.
2006-10-31 03:07:02 +00:00
Nikolaus Schulz 9549c3e29d Minor code cleanup in build_imap_filter(). 2006-10-31 00:35:19 +00:00
Nikolaus Schulz 0b40278a78 The archivemail-devel list is subscribers-only and not very useful as a general
contact address, so better give personal maintainer names and email addresses in
setup.py.
2006-10-30 19:48:25 +00:00
Nikolaus Schulz a221f62f52 Shortened new option name "--dont-mangle-from" to "--dont-mangle". 2006-10-30 19:34:39 +00:00
Nikolaus Schulz 697c22daac Rewrote Mbox.procmail_lock() to fix locking race condition. Should now also be
NFS-safe.
2006-10-30 19:29:15 +00:00
Nikolaus Schulz 700bce69b4 Testsuite: fixed testDeleteOldMail to check the right option. 2006-10-30 18:25:28 +00:00
Nikolaus Schulz daed56f0c5 TODO: added that currently all items are from the original author and still have
to be checked. :-)
2006-10-29 04:09:11 +00:00
Nikolaus Schulz a8e76ead22 Testsuite: create temporary directory with prefix. 2006-10-29 04:05:37 +00:00
Nikolaus Schulz 93015a6d84 Dropped test from testsuite if dotlock file is world-readable, this isn't
required.
2006-10-29 03:59:57 +00:00
Nikolaus Schulz 99cfab1f4e Don't run clean_up() by means of atexit, but use a plain finally clause in the
main archive() function.  This is simpler, and it works better with the
testsuite calling archive() directly, where the atexit handler isn't triggered.
2006-10-29 03:10:45 +00:00
Nikolaus Schulz 2dbd3c1940 Preparing per-testcase cleanup: made StaleFiles.clean() remember what it
deleted, so it's idempotent and e.g. doesn't stomp over someone else's files if
invoked twice and running as root.  Currently I don't see how this could happen,
but it will with a per-testcase cleanup.
2006-10-29 00:04:09 +00:00
Nikolaus Schulz e78b33e115 Updated CHANGELOG. 2006-10-28 18:42:17 +00:00
Nikolaus Schulz bd2f65d0af Changelog: added entry for CRAM-MD5 login to the changelog of the latest
version 0.6.2.
2006-10-28 18:31:29 +00:00
Nikolaus Schulz 5eb4cf3cf6 Replaced all tempfile.mktemp() calls with mkstemp()/mkdtemp().
Should just serve as a last security fallback, since we operate in a safe
temporary directory and everything should be okay anyway, but that may be less
obvious. :-)
2006-10-27 03:23:16 +00:00
Nikolaus Schulz e491da3a11 test_archivemail.py: fixed unsafe creation of temporary files.
Derive all testcases that create temporary files from the new class
TestCaseInTempdir, which provides standard fixtures to set up a secure temporary
root directory for tempfiles and cleaning up afterwards.  This also simplifies
the code. 

This addresses Debian bug #385253, and reading the BTS log, it seems this issue
was assigned CVE-2006-4245, although I cannot find any further reference to that
CVE.  Note that the bug was initially reported to affect archivemail itself,
too.  This is not correct.  There *are* race conditions with archivemail, but
they were not subject of that report, and are not that critical.

Also bumped python dependency to version 2.3 since we use tempfile.mkstemp() and
other recent stuff.
2006-10-27 02:12:45 +00:00
Nikolaus Schulz 0a666a10a6 test_archivemail.py: added two missing self.setUp() calls in the TestArchiveMbox
testcase.
2006-10-27 01:30:49 +00:00
Nikolaus Schulz 7ae1b7bb3f test_archivemail.py: put standard setUp() fixtures in the testcases; the
matching tearDown() methods were already there. 
We surely can move more (possibly duplicated) stuff into the setUp() methods
later.
2006-10-27 01:00:39 +00:00
Nikolaus Schulz ee45d946ed test_archivemail.py: don't check for os.fork(), simply use it -- we're targeting
posix platforms only.
2006-10-27 00:13:48 +00:00
Nikolaus Schulz 06d158c576 Fixed unittest TestMboxExclusiveLock: on some systems flock(2) is emulated with
fcntl(2) calls.  fcntl locks don't support interlocking within a process, so we
need to fork() to correctly test them.
2006-10-20 22:50:38 +00:00
Nikolaus Schulz 157db85b7f Updated manpage:
From_ mangling is only done for messages from mailboxes not in mbox format.
2006-10-18 23:06:29 +00:00
Nikolaus Schulz 39f1d23993 Clarified comment about the python version required to run setup.py. 2006-10-18 01:32:51 +00:00
Nikolaus Schulz 3c0939a3ef When writing messages to mboxes, append os.linesep and mangle From_ only if the
message source is not an mbox-format folder.  
Attempts to fix broken mbox-formatted input are only asking for trouble, and
that's not our job anyway.
2006-10-18 01:20:05 +00:00
Nikolaus Schulz f4c6017d32 IMAPS and IMAP4.login_cram_md5() are new in Python 2.3; bump Python dependency
check to version 2.3.
2006-10-14 23:22:25 +00:00
Nikolaus Schulz ae5e5f63a1 Shorten credits. 2006-10-14 22:49:31 +00:00
Nikolaus Schulz 334d1ef9f1 Updated archivemail.__copyright__ 2006-10-14 22:45:25 +00:00
Nikolaus Schulz 031c6aea7c Extract $(VERSION) from setup.py. 2006-10-14 20:59:14 +00:00
Nikolaus Schulz 3354e35ec9 Disabled bdist_rpm target, it chokes on the manpage. 2006-10-14 20:57:29 +00:00
Nikolaus Schulz a121b1c1d3 Drop fakeroot from sdist rule. Not needed, Debian-specific. 2006-10-14 20:30:14 +00:00
Nikolaus Schulz eb2b4a64f9 Ported "tag" rule to svn, to the extent that's easily possible. 2006-10-14 19:37:08 +00:00
Nikolaus Schulz 4c04117de8 Forgot to commit updated troff manual. 2006-10-13 00:08:37 +00:00
Nikolaus Schulz d0a209fa7a Updated <Date/>, updated AUTHOR section. 2006-10-13 00:07:05 +00:00
Nikolaus Schulz d631079250 Added maintainer entry in setup.py.
Updated copyright notices in archivemail.py and test_archivemail.py.
2006-10-12 23:02:03 +00:00
Nikolaus Schulz b682b26398 Added new option --dont-mangle-from to turn off From_ mangling. 2006-10-12 21:14:04 +00:00
Nikolaus Schulz 6198341eef Made From_ mangling work reliably with large messages, too. 2006-10-12 19:28:30 +00:00
Nikolaus Schulz 88ef628f20 Mangle From_ in message bodies. 2006-10-12 18:19:01 +00:00
Nikolaus Schulz a0994e6a57 Terminate each message in newly written mbox with an empty line. 2006-10-12 17:35:37 +00:00
Nikolaus Schulz 539894ced4 Implemented --dry-run and --delete for IMAP, both do no not download messages.
Stats are still missing.
2006-10-12 01:02:35 +00:00
Nikolaus Schulz 800a957b59 Preparing the implementation of IMAP --delete:
if not dry-running, delete messages whether we archived them or not.
2006-10-11 19:56:50 +00:00
Nikolaus Schulz 27ca6547c5 Kindly shutdown IMAP connection when doing a --dry-run, too. 2006-10-11 19:28:36 +00:00
Nikolaus Schulz b8b64804c9 _archive_imap(): deleted unused variable. 2006-10-11 19:18:43 +00:00
Nikolaus Schulz ab28001c84 Fixed invalid IMAP filter string for large messages (--size option).
Closes: #863813
2006-10-02 00:22:58 +00:00
Nikolaus Schulz 931c2118f3 Removed trailing space from svn:ignore pattern. 2006-10-01 02:35:52 +00:00
Nikolaus Schulz a6ff806d2a Fixed unittest failure by updating --suffix testcase: archivemail used to expand
date directives in the suffix to the current date, but rev. 94 changed that to
the archive cut off date.  Based on analysis by Peter Poeml.  Thanks, Peter.
2006-10-01 02:32:19 +00:00
Nikolaus Schulz 6895571d3b Switched rule for archivemail.html to docbook-tools/docbook-utils.
Since we already run docbook2man, we build-depend on that package anyway, and
the current, hand-crafted jade command fails on Debian systems (wrong path to
stylesheet).
2006-09-29 23:14:10 +00:00
Nikolaus Schulz a8fd65eb5a Added temporary files manpage.{links,refs} from docbook2man to svn:ignore. 2006-09-29 00:53:17 +00:00
Nikolaus Schulz f302156d41 Removed obsolete .cvsignore, svn:ignore ist set accordingly. 2006-09-29 00:31:54 +00:00
Nikolaus Schulz 874f325330 Updated description of the IMAP URL syntax: list the methods to specify the
password, document the IMAPS capability and its syntax.
2006-09-28 23:56:31 +00:00
Nikolaus Schulz 74922b1beb Document new options --pwfile and --filter-append and their short counterparts
in the manual.
2006-09-28 23:49:45 +00:00
Nikolaus Schulz dbe3c9ce4b Fixed typo in description of IMAP URL syntax. 2006-09-28 23:43:50 +00:00
Nikolaus Schulz 140596178c Convert on-the-wire CRLF to native EOL when saving messages from an IMAP folder. 2006-09-28 23:31:47 +00:00
Nikolaus Schulz 8d5b36dc3a Fixed IMAP authentication/URL parsing. Require username encoded in URL, but be
flexible with the password: handle both --pwfile and URL-encoded password, and
fallback to querying the user if neither is present.
2006-09-28 23:26:58 +00:00
Nikolaus Schulz dc023db895 Fixed guess_return_path() to actually extract 'Return-path' and 'From' headers. 2006-09-28 22:26:07 +00:00
Nikolaus Schulz 8f47290956 Fixed long options --filter-append and --pwfile to accept their arguments. 2006-09-28 22:19:12 +00:00
Peter Poeml 75506d9be2 check in the man page, so it doesn't need to be generated locally 2006-06-27 05:38:56 +00:00
Peter Poeml 83ac69d0f8 fix setup.py 2006-06-27 05:25:10 +00:00
Peter Poeml 933aa18259 bump version to 0.6.2 2006-06-27 04:44:28 +00:00
Peter Poeml e00581acb2 new command line option: -F, --filter-append=STRING append arbitrary string to the IMAP filter string 2006-06-27 04:40:24 +00:00
Peter Poeml adfb7a63d7 don't delete more than a certain number of messages at a time. The max command len is limited. Fixes bug 942403 (Archiving large IMAP folders fails) 2006-06-18 11:36:57 +00:00
Peter Poeml 07aca153f6 - fix last patch: don't fail if server URL doesn't contain username of password; try plain as well as cram-md5 login 2006-06-16 09:22:47 +00:00
Peter Poeml a91b2064cb - add SSL support per imaps URL (after patch by Tobias Gruetzmacher)
- add -P/--pwfile option to supply the IMAP password, so it does not end up in the shell history
2006-06-16 08:34:22 +00:00
Peter Poeml 05c599028e fix SyntaxWarning: assignment to None (bug #843890) 2006-04-25 21:13:53 +00:00
Paul Rodger 64d87da307 Use the archive cut-off date rather than the current time with the
--suffix option.
2002-11-21 22:57:13 +00:00
Paul Rodger 60f119d64a Don't assume that root's grpid is '0' -- on solaris it can be different. 2002-11-07 22:54:03 +00:00
Paul Rodger 9d08aca3b9 Fixed date typo. 2002-10-30 23:54:23 +00:00
Paul Rodger 799f4affcd Removed a test rule that says we can confidently archive messages
older than the unix epoch. (New versions of python return OverFlow
error instead)
2002-10-30 23:51:08 +00:00
22 changed files with 5206 additions and 3258 deletions

View File

@ -1,5 +0,0 @@
archivemail.1
archivemail.html
build
dist
*.pyc

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/archivemail.1
/archivemail.html
/MANIFEST

195
CHANGELOG
View File

@ -1,3 +1,198 @@
version 0.9.0 - 9 July 2011
* Fixed manpage installation path to be FHS compliant
* Speed up IMAP archiving with the --quiet option
* Ported the manpage from SGML to XML
* Fix test suite failures with Python 2.7. Closes: #3314293.
* IMAP: support international mailbox names containing non-ASCII characters.
* IMAP: handle broken servers sending no untagged SEARCH response.
Closes: #879716, #3213272.
* IMAP: support servers listening on non-standard ports. Closes: #3168416.
version 0.8.2 - 16 October 2010
* IMAP: don't prepend NAMESPACE prefix to INBOX and its children.
Closes: #3083236.
version 0.8.1 - 30 September 2010
* IMAP: fixed handling of LIST replies by the server where the mailbox name
is not a quoted string. (Thanks Karsten Müller)
Version 0.8.0 - 9 August 2010
* Fixed date header parsing to be precise with timezone information. Also,
when writing From_ line timestamps, don't use UTC but local time, without
timezone information.
* To determine the delivery date of a message, archivemail now looks for the
timestamp of the latest 'Received' header before resorting to
'Resent-Date' or 'Date'. This should give much better results when there
is no 'Delivery-date' header, which is still checked first.
(Thanks Andrew Ferrier & Christian Brabandt)
Closes: #1481316, #1764855, Debian bug #272666.
* If present, the 'Resent-date' header now takes precedence over 'Date'.
* IMAP: recognize when a server advertises LOGINDISABLED.
* New option --debug-imap; this just sets imaplib.Debug, thereby dumping
archivemail's chat with the server to stdout.
* Fixed crash with Python 2.5 when archiving an empty maildir.
(Thanks "Aidant") Closes: #1878940.
* New option --all to archive all messages in a mailbox. Closes: #1764846.
* Fixed a crash when archiving maildirs with --days=0. (Thanks John Goerzen)
* IMAP: automatically add NAMESPACE prefix to a mailbox path if necessary.
* Removed the feature to setuid to the mailbox owners when run as root.
This was a bad idea; it's really hard to do safely, if at all possible.
Obsoletes: patch #2783134.
* Replaced some simple minded file operation security checks with more
decent ones. This means we can safely operate in /tmp, for example. The
price is that we no longer accept symlinked files. Obsoletes: patch
#1874868.
* Don't use rename() to update mbox files and the archive, but write the
files directly. This is more fragile, but required for correct mbox
locking, and also for mboxes in mail spool directories where we don't have
permission to create files. It also means that if selinux is enabled,
archivemail now preserves the selinux security context of an mbox.
Closes: #2210732.
* Fixed the test suite to deal with nanosecond file timestamps. These are
provided by ext4 and XFS, for example. Closes: #2043900.
* Cleaned up the test suite, replacing a lot of duplicated code and avoiding
a lot of redundand testing. This speeds up the test suite by a factor of
15 or so.
* mbox locking got completely rewritten. Switched from flock to lockf
locking, which is NFS-safe and portable, and we now lock with lockf first,
then with a dotlock, instead of the other way around. (This is makes
archivemail compatible with Debian systems. ;)
* We now omit the dotlock if we don't have sufficient permissions to create
it in the mbox directory. (The file is still locked with lockf.)
Since we also no longer use rename() to commit changes to an mbox, (see
above) this means archivemail can now operate on mbox files in the system
mail spool. Closes: #855269.
* Refactoring of the mbox classes; much of the code got rewritten.
* The archive now also gets locked while archivemail updates it.
* Various Python language fixes (for example don't use "0" and "1" as
boolean constants).
* Added a lot of test cases for maildir archiving to the test suite.
Maildir testing should now be roughly on par with mbox testing.
* IMAP servers (Dovecot and UW-IMAP at least) may store mailbox meta data
for mboxes in a pseudo message. Such messages are now detected and never
archived. Obsoletes: patch #2210707. (Thanks, "tlhackque")
* New option --prefix, or short -p, to specify an archive name prefix. Like
a suffix specified with the --suffix option, the prefix is expanded with
strftime(). Specifying this option disables the default archive name
suffix. Obsoletes: feature request #604281. (Thanks Serafeim Zanikolas
for an initial patch)
* When archiving a mailbox with a leading dot in the name and with no archive
name prefix specified, archivemail no longer creates hidden archives, but
strips the dot off the archive name. In particular, this makes working
with Maildir++ subfolders more convenient. Closes: feature request
#604281.
* New option --archive-name, or short -a, to hard-code an archive filename.
Like the --suffix and --prefix options, it is expanded with strftime().
This option conflicts with archiving multiple mailboxes. Closes: feature
request #1306538.
* archivemail now expands wildcards in IMAP mailbox names. For example, the
url imaps://user@server/foo/* will expand to all subfolders of foo.
Closes: feature request #1978540. Obsoletes: patch #1918937.
Version 0.7.2 - 9 November 2007
* IMAP: fixed crash by working around python bug #1277098, which is still pending
in python << 2.5.
Version 0.7.1 - 7 November 2007
* Fixed incompatibility with Python 2.5 which broke Maildir handling.
Closes: #1670422
* Username and password in IMAP URLs can now be double-quoted, so it should be
no longer a problem if they contain delimiters like the '@' character.
Closes: #1640878
* Invalid messages/files in Maildirs caused archivemail to silently stop
processing mails and claim it's all done. Now skip these and go ahead.
(Thanks Elan Ruusamäe for tracking this down.) Closes: #1783369.
(The Debian package has a different fix for this problem since 0.6.1-4,
closing Debian bugs #255944 and #305902.)
* Fixed IMAP message flag conversion which was completely broken. (Thanks
Christian Brabandt) Closes: Debian bug #434807
* New option --copy: archive mail, but don't delete it from the mailbox.
This is mainly useful for testing purposes, and complements --delete.
Closes: #981865, #988803, #1764851, Debian bug #434798
* If running as root, only switch the effective uid and gid back if we have
actually switched them before. Closes: #1762907
* The automatic seteuid feature of archivemail is insecure and thus
deprecated; it will be removed from later versions.
* Expand tilde in argument of long option --pwfile. (Thanks Christian
Brabandt) Closes: Debian bug #434813
* archivemail now accepts --days=0
* Fixed crash if --warn-duplicate is used with IMAP (Thanks Christian
Brabandt) Closes: Debian bug #434786 (the Debian package already has a fix)
* When converting from other formats to mbox, archivemail used to preserve
existing 'Status' and 'X-Status' mbox headers; these are now silently
overwritten to ensure they have correct values.
* IMAP: if selecting the mailbox fails, archivemail detects the server's
mailbox hierarchy delimiter, replaces slashes in the mailbox name with the
delimiter and tries again. Closes: #1826757, Debian bug #368112
Version 0.7.0 - 2 November 2006
* Fixed long options --filter-append and --pwfile to accept their arguments.
Closes: #1555935
* Fixed From_ line generation to actually look for the 'Return-path' and
'From' headers. Closes: #1555797
* Fixed IMAP authentication/URL parsing, which wasn't working at all in
v0.6.2. Require username encoded in URL, but be flexible with the password:
handle both --pwfile and URL-encoded password, and fallback to querying the
user if neither is present. Closes: #1555951
* Convert on-the-wire CRLF to native EOL when saving messages from an IMAP
folder. Closes: #1555803
* Updated man page. This also addresses #1555951
* Fixed unittest failure by updating --suffix testcase. Based on analysis by
Peter Poeml. Thanks, Peter.
* Fixed invalid IMAP filter string for large messages (--size option).
(Thanks to the anonymous bug reporter) Closes: #863813
* Fixed IMAP --dry-run so it doesn't download all messages that would be
archived.
* Fixed IMAP --delete which didn't work at all. (Thanks Anand)
Closes: Debian bug #203282
* Terminate each message in newly written mbox with an empty line if the
message source is not an mbox-format folder. (Thanks Chung-chieh Shan)
Closes: Debian bug #250410
* Mangle From_ in message body if the message source is not an mbox-format
folder. (Thanks Chung-chieh Shan) Closes: Debian bug #250402
* Added new option --dont-mangle to turn off From_ mangling.
* Bumped Python dependency to version 2.3.
* Fixed unittest TestMboxExclusiveLock which failed on Solaris. (Thanks Paul
Rodger) Closes: #904652
* Fixed unsafe creation of temporary files in the test suite.
This addresses Debian bug #385253, and reading the BTS log, it seems this
issue was assigned CVE-2006-4245, although I cannot find any further
reference to that CVE. Note that the bug was initially reported to affect
archivemail itself, too. This is not correct. (Thanks Joey Hess)
Closes: Debian bug #385253
* Fixed cleanup of temporary files after test suite failures.
* Fixed dotlocking race condition.
* Stats are now working with IMAP.
* Stats now report the total size of a mailbox and of the archived messages
therefrom.
* Always barf if the archive destination directory is world-writable.
* Distributing man page with the tarball again and fixed distutils setup.
Closes: #1574720 (Thanks Grant Goodyear)
* Improved IMAP error reporting
Version 0.6.2 - 27 June 2006
* add -F/--filter-append option to append an arbitrary string to the IMAP
filter string
* don't delete more than a certain number of messages at a time. The max
command len is limited. Fixes bug 942403 (Archiving large IMAP folders fails)
* IMAP: try CRAM-MD5 login first, if that fails fallback to plain login
* add SSL support per imaps URL (after patch by Tobias Gruetzmacher)
* add -P/--pwfile option to supply the IMAP password, so it does not end up in
the shell history
* Fix SyntaxWarning: assignment to None (bug #843890)
* Use the archive cut date rather than the actual time with the --suffix
option. (Thanks Manuel Estrada Sainz)
Version 0.6.1 - 31 October 2002
* Removed a test rule that we could archive messages older than the
Unix epoch. Newer versions of python now give an overflow error calling
mktime() on dates < 1970 instead of returning a negative number.
Version 0.6.0 - 3 October 2002
* Added IMAP mailbox support. (Thanks Mark Roach)

7
FAQ
View File

@ -2,10 +2,9 @@
1. Why doesn't archivemail support bzip2 compression in addition to gzip?
-------------------------------------------------------------------------
I am quite happy to add bzip2 support to archivemail as soon as a 'bzip2'
module (similar to the gzip module) is available for python.
[ Hint hint ;) ]
The bzip2 module in Python 2.x is not fully compatible with the gzip module,
and cannot be used with the current implementation of compressed mailbox
support in archivemail. See Python feature request #5863 for details.
2. Can you add a switch to archive mailboxes greater than a certain size?
-------------------------------------------------------------------------

View File

@ -1,12 +0,0 @@
CHANGELOG
COPYING
FAQ
MANIFEST
README
TODO
archivemail
archivemail.1
archivemail.sgml
examples/archivemail_all
setup.py
test_archivemail.py

11
MANIFEST.in Normal file
View File

@ -0,0 +1,11 @@
include CHANGELOG
include COPYING
include FAQ
include MANIFEST
include TODO
include NEWS
include archivemail.1
include archivemail.xml
include db2man.xsl
graft examples
include test_archivemail

View File

@ -1,49 +1,43 @@
VERSION=0.6.0
VERSION=$(shell python setup.py --version)
VERSION_TAG=v$(subst .,_,$(VERSION))
TARFILE=archivemail-$(VERSION).tar.gz
HTDOCS=htdocs-$(VERSION)
default:
@echo "no default target"
clean:
rm -f *.pyc manpage.links manpage.refs manpage.log
rm -rf $(HTDOCS)
test:
python test_archivemail.py
python test_archivemail
clobber: clean
rm -rf build dist
rm -f $(HTDOCS).tgz
sdist: clobber doc
cp archivemail.py archivemail
fakeroot python setup.py sdist
rm archivemail
bdist_rpm: clobber doc
cp archivemail.py archivemail
fakeroot python setup.py bdist_rpm
rm archivemail
python setup.py sdist
tag:
cvs tag -F current
cvs tag -F $(VERSION_TAG)
upload:
(cd dist && lftp -c 'open upload.sf.net && cd incoming && put $(TARFILE)')
git tag -a $(VERSION_TAG)
doc: archivemail.1 archivemail.html
archivemail.1: archivemail.sgml
docbook2man archivemail.sgml
chmod 644 archivemail.1
htdocs: $(HTDOCS).tgz
$(HTDOCS).tgz: index.html archivemail.html RELNOTES style.css manpage.css
install -d -m 775 $(HTDOCS)
install -m 664 $^ $(HTDOCS)
cd $(HTDOCS) && mv archivemail.html manpage.html
tar czf $(HTDOCS).tgz $(HTDOCS)
archivemail.html: archivemail.sgml
jade -t sgml \
-d /usr/lib/sgml/stylesheet/dsssl/docbook/nwalsh/html/docbook.dsl \
-o archivemail.html \
archivemail.sgml
mv r1.html archivemail.html
chmod 644 archivemail.html
archivemail.1: archivemail.xml db2man.xsl
xsltproc db2man.xsl archivemail.xml
archivemail.html: archivemail.xml db2html.xsl
xsltproc --output archivemail.html \
db2html.xsl archivemail.xml
tidy -modify -indent -f /dev/null archivemail.html || true
.PHONY: default clean test clobber sdist tag doc htdocs

44
NEWS Normal file
View File

@ -0,0 +1,44 @@
Notable changes in archivemail 0.9.0:
* IMAP: support for international mailbox names containing non-ASCII
characters.
Notable changes in archivemail 0.8.0:
* Removed the feature to setuid to the mailbox owners when run as root.
This was a bad idea; it's really hard to do safely, if at all possible.
Obsoletes: patch #2783134.
* New option --archive-name, or short -a, to hard-code an archive filename.
Like the --suffix and --prefix options, it is expanded with strftime().
This option conflicts with archiving multiple mailboxes. Closes: feature
request #1306538.
* New option --prefix, or short -p, to specify an archive name prefix. Like
a suffix specified with the --suffix option, the prefix is expanded with
strftime(). Specifying this option disables the default archive name
suffix. Obsoletes: feature request #604281. (Thanks Serafeim Zanikolas
for an initial patch)
* New option --all to archive all messages in a mailbox. Closes: #1764846.
* archivemail now expands wildcards in IMAP mailbox names. For example, the
url imaps://user@server/foo/* will expand to all subfolders of foo.
Closes: feature request #1978540. Obsoletes: patch #1918937.
* To determine the delivery date of a message, archivemail now looks for the
timestamp of the latest 'Received' header before resorting to
'Resent-Date' or 'Date'. This should give much better results when there
is no 'Delivery-date' header, which is still checked first.
(Thanks Andrew Ferrier & Christian Brabandt)
Closes: #1481316, #1764855, Debian bug #272666.
* We now omit the dotlock if we don't have sufficient permissions to create
it in the mbox directory. (The file is still locked with lockf.)
Together with more changes under the hood (see below) this means
archivemail can now operate on mbox files in the system mail spool.
Closes: #855269.
* Replaced some simple minded file operation security checks with more
decent ones. This means we can safely operate in /tmp, for example. The
price is that we no longer accept symlinked files. Obsoletes: patch
#1874868.
* The archive now also gets locked while archivemail updates it.
* mbox locking got completely rewritten. Switched from flock to lockf
locking, which is NFS-safe and portable, and we now lock with lockf first,
then with a dotlock, instead of the other way around. (This is makes
archivemail compatible with Debian systems. ;)

35
README
View File

@ -25,36 +25,17 @@ by an absolute date or only archive unread messages.
REQUIREMENTS:
archivemail requires python version 2.0 or later, with the optional 'zlib'
module, although the zlib module comes with most python installations. If you
are compiling your own version of python < version 2.2, make sure you
uncomment the 'zlib' moduile in Modules/Setup in the python source directory.
You can check to see if your version of python has the 'zlib' module by
trying this:
flare:~$ python
Python 2.1 (#1, Apr 26 2002, 11:22:45)
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import zlib
>>>
If you get an ImportError, then the zlib python module has not been installed.
Try upgrading your python distribution.
archivemail requires python version 2.3. It also uses some optional python
modules, but these should be pretty much standard; if you get an ImportError
nonetheless, please report it, thanks. (For contact addresses see below.)
Python is available from http://www.python.org/
If you want to run the bundled test script, you will need python version 2.1
or later, because we use the PyUnit 'unittest' module. Sorry.
INSTALLATION:
If you want to test archivemail:
cp archivemail archivemail.py
python test_archivemail.py
(NOTE: This could take over 90 seconds on slower systems)
python test_archivemail
To install archivemail, run:
python setup.py install
@ -72,7 +53,11 @@ cron.
The archivemail website is at: http://archivemail.sourceforge.net/
If you have any feedback or bug reports about archivemail, you are very
welcome to email me.
welcome to email the maintainers; as of November 2006, these are:
Nikolaus Schulz <microschulz@web.de>
Peter Poeml <poeml@suse.de>
-- Paul Rodger <paul at paulrodger dot com>
-- Paul Rodger <paul at paulrodger dot com>, archivemail author
Updated by: Nikolaus Schulz, maintainer

122
TODO
View File

@ -1,23 +1,103 @@
Integrate --debug-imap option into yet-to-be-implemented -vv switch?
I had the idea to provide separate debugging info levels anyway, see --debug
below.
Goals for next minor release
-------------------------------------
* When you get a file-not-found in the 6th mailbox of 10, it aborts the whole
run. Better to fail gracefully and keep going.
* Think about the best way to specify the names of archives created with
possibly an --archive-name option.
* Add more tests (see top of test_archivemail.py)
* We need some better checking to see if we are really looking at a valid
mbox-format mailbox.
* Lock any original .gz files
- is this necessary?
* Check for symlink attacks for tempfiles (although we don't use /var/tmp)
Gracefully close IMAP connection upon unexptected error (currently archivemail
just terminates).
Longer Term goals:
------------------
* Add an option to not cut threads.
* Add MMDF mailbox support
* Add Babyl mailbox support
* Add option to archive depending on mailbox size threshold
- is this a good idea?
* Add option to archive depending on number of messages
- is this a good idea?
LOCKING & Co:
* Block signals while writing changed mailbox back.
* Double-check the entire locking code.
Seems like existing archives are not read or validated in any way. New archive
data is blindly appended... Probably okay, but should be documented.
IMAP SEARCH BEFORE disregards time and timezone information. This should at
least be documented. E.g. I've found that '-d 0' didn't match all messages in
an IMAP mailbox. This is because the SEARCH key is (BEFORE 14-Nov-2007) on 14
November, not matching messages that arrived today. (This problem is probably
fixed for most use cases by the --all option.)
Document mbox format issues: link to
http://homepages.tesco.net/~J.deBoynePollard/FGA/mail-mbox-formats.html,
qmail mbox manpage, Debian manpage, RFC 4155. Document what mbox format we can
read, and what we write.
FIXME: we cannot yet parse rfc 2822 addr-spec stuff like quoted local-parts in
return-path addresses.
Minor annoyance: when a From_ line is generated, guess_delivery_time() reports
the used date header a second time.
Check sf.net and Debian BTS for new bugs. Again.
IMAP: ensure mailbox archives are properly named. Currently imap folder names
are mapped like this:
IMAP URL | resulting mbox_archive
------------+------------------------
test.box | test.box_archive.gz
test/box | box_archive.gz
Implement --include-draft. But before, think about it again. (This is feature
request #1569305.)
Implement a fallback if an IMAP server doesn't support SEARCH. (Ouch!)
Add IMAP tests to the testsuite (upload test messages with IMAP "APPEND
date-string"). This should be done without any real network I/O.
Try to port archivemail to email.message and the new mailboxes in Python 2.5.
Is these flexible enough for our needs?
Line out what we want with respect to multiple selection criteria.
Some make sense, but this easily gets too complex, and if only it's a hassle
with adding all the options. Hm.
Reject patch #1036022 "Added option to inverse date compare" after cooling down
because the patch is both stupid (copy+paste code) and broken. Don't see why
anyone should want this/we should support it.
If this is reasonable *at all*, I think we'd better go for all the complexity
to honour _two_ cut off dates (see Debian bug "#184124: archivemail: -D and -d
should not be incompatible", which is a comparably half-baken thought). </rant>
Add --debug or -vv switch, and move the printing of diagnostic info for each
message to --debug.
Perhaps add some more nice stuff like printing of subject, sender...
See tracker #868714 "added stats option to archivemail", which has a point.
Message-Ids are useful for diagnosis, but not very nice to read for humans.
Be a nicer citizen with respect to mailbox locking.
Perhaps prune/shorten IMAP mailbox URLs in messages?
They may be quite long and may contain the sensitive password.
Also shows up in the process list...
Perhaps find a clean, lean replacement for all that clutter in the IMAP urls.
Require --output-dir for IMAP archiving? Otherwise we just drop the archive in
in the current working directory.
Check all items below, which are from the original author. :-)
.archivemailrc support
When you get a file-not-found in the 6th mailbox of 10, it aborts the whole
run. Better to fail gracefully and keep going.
Add more tests (see top of test_archivemail)
We need some better checking to see if we are really looking at a valid
mbox-format mailbox.
Add an option to not cut threads.
Add MMDF mailbox support
Add Babyl mailbox support
Add option to archive depending on mailbox size threshold
- is this a good idea?
Add option to archive depending on number of messages
- is this a good idea?

1951
archivemail Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,488 +0,0 @@
<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" [
<!ENTITY flock "<CiteRefEntry>
<RefEntryTitle><Command/flock/</RefEntryTitle>
<ManVolNum/2/</CiteRefEntry>">
<!ENTITY gzip "<CiteRefEntry>
<RefEntryTitle><Command/gzip/</RefEntryTitle>
<ManVolNum/1/</CiteRefEntry>">
<!ENTITY mutt "<CiteRefEntry>
<RefEntryTitle><Command/mutt/</RefEntryTitle>
<ManVolNum/1/</CiteRefEntry>">
<!ENTITY procmail "<CiteRefEntry>
<RefEntryTitle><Command/procmail/</RefEntryTitle>
<ManVolNum/1/</CiteRefEntry>">
<!ENTITY python "<CiteRefEntry>
<RefEntryTitle><Command/python/</RefEntryTitle>
<ManVolNum/1/</CiteRefEntry>">
<!ENTITY seteuid "<CiteRefEntry>
<RefEntryTitle><Command/seteuid/</RefEntryTitle>
<ManVolNum/2/</CiteRefEntry>">
<!ENTITY crontab "<CiteRefEntry>
<RefEntryTitle><Command/crontab/</RefEntryTitle>
<ManVolNum/5/</CiteRefEntry>">
]>
<RefEntry>
<DocInfo><Date>12 April 2002</Date></DocInfo>
<RefMeta>
<RefEntryTitle>archivemail</RefEntryTitle>
<ManVolNum>1</ManVolNum>
<RefMiscInfo>SP</RefMiscInfo>
</RefMeta>
<RefNameDiv>
<RefName>archivemail</RefName>
<RefPurpose>archive and compress your old email</RefPurpose>
</RefNameDiv>
<RefSynopsisDiv>
<CmdSynopsis>
<Command/archivemail/
<Arg><Option>options</Option></Arg>
<Arg choice=req rep=repeat><Replaceable/MAILBOX/</Arg>
</CmdSynopsis>
</RefSynopsisDiv>
<RefSect1>
<Title>Description</Title>
<Para>
<Command/archivemail/ is a tool written in &python; for archiving and
compressing old email in mailboxes.
</Para>
<Para>
By default it will read the mailbox <Replaceable/MAILBOX/, moving messages
that are older that the specified number of days (180 by default) to a
<application/mbox/-format mailbox in the same directory that is compressed
with &gzip;.
</Para>
<Para>
<Command/archivemail/ supports reading <application/IMAP/,
<application/Maildir/, <application/MH/ and <application/mbox/-format
mailboxes, but it will always write archive files to <application/mbox/-format
mailboxes that are compressed with &gzip;.
</Para>
<Para>
<Command/archivemail/ has some support for being run as the root user on
user mailboxes. When running as root, it will &seteuid; to the owner of the
mailbox it is reading, creating any archive files as that user.
</Para>
</RefSect1>
<RefSect1>
<Title>Options</Title>
<VariableList>
<VarListEntry>
<Term>
<Option>-d <Replaceable/NUM/, --days=<Replaceable/NUM/</Option>
</Term>
<ListItem><Para>Archive messages older than <Replaceable/NUM/ days.
The default is 180. This option is incompatible with the
<Option/--date/ option below.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-D <Replaceable/DATE/, --date=<Replaceable/DATE/</Option>
</Term>
<ListItem><Para>Archive messages older than <Replaceable/DATE/.
<Replaceable/DATE/ can be a date string in ISO format (eg '2002-04-23'),
Internet format (eg '23 Apr 2002') or Internet format with full month names
(eg '23 April 2002'). Two-digit years are not supported.
This option is incompatible with the <Option/--days/ option above.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-o <Replaceable/PATH/, --output-dir=<Replaceable/PATH/</Option>
</Term>
<ListItem><Para>Use the directory name <Replaceable/PATH/ to store the
mailbox archives. The default is the same directory as the mailbox to be
read.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-s <Replaceable/NAME/, --suffix=<Replaceable/NAME/</Option>
</Term>
<ListItem><Para>
Use the suffix <Replaceable/NAME/ to create the filename used for archives.
The default is <filename>_archive</filename>. For example, if you
run <Command/archivemail/ on a mailbox called
<filename>exsouthrock</filename>, the archive will be created
with the filename <filename>exsouthrock_archive.gz</filename>.
</Para>
<Para>
<Replaceable/NAME/ is run through the &python; <application/time.strftime()/
function, which means that you can specify any of the following special
directives in <Replaceable/NAME/ to make archives named after the current
date:
<itemizedlist mark='none'>
<listitem><para><option>%a</option>
Locale's abbreviated weekday name.</para></listitem>
<listitem><para><option>%A</option>
Locale's full weekday name.</para></listitem>
<listitem><para><option>%b</option>
Locale's abbreviated month name.</para></listitem>
<listitem><para><option>%B</option>
Locale's full month name.</para></listitem>
<listitem><para><option>%c</option>
Locale's appropriate date and time representation.</para></listitem>
<listitem><para><option>%d</option>
Day of the month as a decimal number [01,31].</para></listitem>
<listitem><para><option>%H</option>
Hour (24-hour clock) as a decimal number [00,23].</para></listitem>
<listitem><para><option>%I</option>
Hour (12-hour clock) as a decimal number [01,12].</para></listitem>
<listitem><para><option>%j</option>
Day of the year as a decimal number [001,366].</para></listitem>
<listitem><para><option>%m</option>
Month as a decimal number [01,12].</para></listitem>
<listitem><para><option>%M</option>
Minute as a decimal number [00,59].</para></listitem>
<listitem><para><option>%p</option>
Locale's equivalent of either AM or PM.</para></listitem>
<listitem><para><option>%S</option>
Second as a decimal number [00,61]. (1)</para></listitem>
<listitem><para><option>%U</option>
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.</para></listitem>
<listitem><para><option>%w</option>
Weekday as a decimal number [0(Sunday),6].</para></listitem>
<listitem><para><option>%W</option>
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.</para></listitem>
<listitem><para><option>%x</option>
Locale's appropriate date representation.</para></listitem>
<listitem><para><option>%X</option>
Locale's appropriate time representation.</para></listitem>
<listitem><para><option>%y</option>
Year without century as a decimal number [00,99].</para></listitem>
<listitem><para><option>%Y</option>
Year with century as a decimal number.</para></listitem>
<listitem><para><option>%Z</option>
Time zone name (or by no characters if no time zone exists).</para></listitem>
<listitem><para><option>%%</option>
A literal "%" character.</para></listitem>
</itemizedlist>
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-S <Replaceable/NUM/, --size=<Replaceable/NUM/</Option>
</Term>
<ListItem><Para>Only archive messages that are <Replaceable/NUM/ bytes or
greater.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-n, --dry-run</Option>
</Term>
<ListItem><Para>
Don't 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.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-u, --preserve-unread</Option>
</Term>
<ListItem><Para>
Do not archive any messages that have not yet been read. <command/archivemail/
determines if a message in a <application/mbox/-format or
<application/MH/-format mailbox has been read by looking at the
<application/Status/ header (if it exists). If the status
header is equal to 'RO' or 'OR' then <application/archivemail/ assumes the
message has been read. <command/archivemail/ determines if a
<application/maildir/ message has
been read by looking at the filename. If the filename contains an 'S' after
<filename>:2,</filename> then it assumes the message has been read.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>--delete</Option>
</Term>
<ListItem><Para>
Delete rather than archive old mail. Use this option with caution!
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>--include-flagged</Option>
</Term>
<ListItem><Para>
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.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>--no-compress</Option>
</Term>
<ListItem><Para>
Do not compress any archives using &gzip;.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>--warn-duplicate</Option>
</Term>
<ListItem><Para>
Warn about duplicate <application/Message-ID/s that appear in the input
mailbox.</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-v, --verbose</Option>
</Term>
<ListItem><Para>
Reports lots of extra debugging information about what is going on.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-q, --quiet</Option>
</Term>
<ListItem><Para>
Turns on quiet mode. Do not print any statistics about how many messages were
archived. This should be used if you are running <Command/archivemail/ from
cron.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-V, --version</Option>
</Term>
<ListItem><Para>
Display the version of <Command/archivemail/ and exit.
</Para></ListItem>
</VarListEntry>
<VarListEntry>
<Term>
<Option>-h, --help</Option>
</Term>
<ListItem><Para>
Display brief summary information about how to run <Command/archivemail/.
</Para></ListItem>
</VarListEntry>
</VariableList>
</RefSect1>
<RefSect1>
<Title>Notes</Title>
<Para>
<Command/archivemail/ requires &python; version 2.0 or later.
</Para>
<Para>
To archive an <application/IMAP/-format mailbox, use the the format
<command>imap://username:password@server/mailbox</command> to specify the
mailbox.
</Para>
<Para>
When reading an <application/mbox/-format mailbox, <command/archivemail/ will
create a lockfile with the extension <filename>.lock</filename> so that
procmail will not deliver to the mailbox while it is being processed. It will
also create an advisory lock on the mailbox using &flock;.
<command/archivemail/ will also complain and abort if a 3rd-party modifies the
mailbox while it is being read.
</Para>
<Para>
<Command/archivemail/ will always attempt to preserve the mode,
last-access and last-modify times of the input mailbox. However, archive
mailboxes are always created with a mode of <application/0600/.
</Para>
<Para>
If <Command/archivemail/ finds a pre-existing archive mailbox it
will append rather than overwrite that archive.
</Para>
<Para>
<Command/archivemail/ attempts to find the delivery date of a message by
looking for valid dates in the following headers, in order of precedence:
<application/Delivery-date/,
<application/Date/ and
<application/Resent-Date/.
If it cannot find any valid date in these headers, it
will use the last-modified file timestamp on <application/MH/ and
<application/Maildir/ format mailboxes, or the date on the
<application/From/ line on <application/mbox/-format mailboxes.
</Para>
<Para>
<Command/archivemail/ will refuse to operate on mailboxes that are symbolic
links or create tempfiles or archives in world-writable directories.
</Para>
</RefSect1>
<RefSect1>
<Title>Examples</Title>
<Para>
To archive all messages in the mailbox <filename>debian-user</filename> that
are older than 180 days to a compressed mailbox called
<filename>debian-user_archive.gz</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail debian-user</userinput>
</screen>
</Para>
<Para>
To archive all messages in the mailbox <filename>debian-user</filename> that
are older than 180 days to a compressed mailbox called
<filename>debian-user_April_2002.gz</filename> (where the current month and
year is April, 2002) in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --suffix '_%B_%Y' debian-user</userinput>
</screen>
</Para>
<Para>
To archive all messages in the mailbox <filename>cm-melb</filename> that
are older than the first of January 2002 to a compressed mailbox called
<filename>cm-melb_archive.gz</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --date'1 Jan 2002' cm-melb</userinput>
</screen>
</Para>
<Para>
Exactly the same as the above example, using an ISO date format instead:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --date=2002-01-01 cm-melb</userinput>
</screen>
</Para>
<Para>
To delete all messages in the mailbox <filename>spam</filename> that
are older than 30 days:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --delete --days=30 spam</userinput>
</screen>
</Para>
<Para>
To archive all read messages in the mailbox <filename>incoming</filename> that
are older than 180 days to a compressed mailbox called
<filename>incoming_archive.gz</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --preserve-unread incoming</userinput>
</screen>
</Para>
<Para>
To archive all messages in the mailbox <filename>received</filename> that
are older than 180 days to an uncompressed mailbox called
<filename>received_archive</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --no-compress received</userinput>
</screen>
</Para>
<Para>
To archive all mailboxes in the directory <filename>$HOME/Mail</filename>
that are older than 90 days to compressed mailboxes in the
<filename>$HOME/Mail/Archive</filename> directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail -d90 -o $HOME/Mail/Archive $HOME/Mail/*</userinput>
</screen>
</Para>
</RefSect1>
<RefSect1>
<Title>Tips</Title>
<Para>
Probably the best way to run <Command/archivemail/ is from your &crontab;
file, using the <Option>--quiet</Option> option.
</Para>
<Para>
Don't forget to try the <Option>--dry-run</Option> option for non-destructive
testing.
</Para>
</RefSect1>
<RefSect1>
<Title>Exit Status</Title>
<SimPara>Normally the exit status is 0. Nonzero indicates an unexpected error.
</SimPara>
</RefSect1>
<RefSect1>
<Title>Bugs</Title>
<SimPara>
There is no support yet for reading <application/MMDF/ or
<application/Babyl/-format mailboxes. In fact, <Command/archivemail/ will
probably think it is reading an <application/mbox/-format mailbox and cause
all sorts of problems.
</SimPara>
<SimPara>
<Command/archivemail/ is still too slow, but if you are running from &crontab;
you won't care. Archiving <application/maildir/-format mailboxes should be
a lot quicker than <application/mbox/-format mailboxes since it is less
painful for the original mailbox to be reconstructed after selective message
removal.
</SimPara>
</RefSect1>
<RefSect1>
<Title>See Also</Title>
<SimpleList>
<Member> &python;, &gzip;, &mutt;, &procmail;</Member>
</SimpleList>
</RefSect1>
<RefSect1>
<Title>Url</Title>
<SimPara>The <Command/archivemail/ home page is currently hosted at
<ulink type="http" url="http://archivemail.sourceforge.net">sourceforge</ulink>
</SimPara>
</RefSect1>
<RefSect1>
<Title>Author</Title>
<SimPara>Paul Rodger &lt;paul at paulrodger dot com&gt;</SimPara>
</RefSect1>
</RefEntry>

794
archivemail.xml Normal file
View File

@ -0,0 +1,794 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"file:///usr/share/xml/docbook/schema/dtd/4.2/docbookx.dtd" [
<!ENTITY lockf '<citerefentry>
<refentrytitle><emphasis role="bold">lockf</emphasis></refentrytitle>
<manvolnum>2</manvolnum></citerefentry>'>
<!ENTITY gzip '<citerefentry>
<refentrytitle><emphasis role="bold">gzip</emphasis></refentrytitle>
<manvolnum>1</manvolnum></citerefentry>'>
<!ENTITY procmail '<citerefentry>
<refentrytitle><emphasis role="bold">procmail</emphasis></refentrytitle>
<manvolnum>1</manvolnum></citerefentry>'>
<!ENTITY python '<citerefentry>
<refentrytitle><emphasis role="bold">python</emphasis></refentrytitle>
<manvolnum>1</manvolnum></citerefentry>'>
<!ENTITY crontab '<citerefentry>
<refentrytitle><emphasis role="bold">crontab</emphasis></refentrytitle>
<manvolnum>5</manvolnum></citerefentry>'>
<!ENTITY mbox '<citerefentry>
<refentrytitle><emphasis role="bold"><acronym>mbox</acronym></emphasis></refentrytitle>
<manvolnum>5</manvolnum></citerefentry>'>
]>
<refentry>
<docinfo><date>5 July 2011</date></docinfo>
<refmeta>
<refentrytitle>archivemail</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">archivemail user manual</refmiscinfo>
<refmiscinfo class="source">archivemail 0.9.0</refmiscinfo>
</refmeta>
<refnamediv>
<refname>archivemail</refname>
<refpurpose>archive and compress your old email</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>archivemail</command>
<arg><option>options</option></arg>
<arg choice="req" rep="repeat"><replaceable>MAILBOX</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>archivemail</command> is a tool for archiving and compressing old
email in mailboxes.
By default it will read the mailbox <replaceable>MAILBOX</replaceable>, moving
messages that are older than the specified number of days (180 by default) to
a &mbox;-format mailbox in the same directory that is compressed with &gzip;.
It can also just delete old email rather than archive it.
</para>
<para>
By default, <command>archivemail</command> derives the archive filename from
the mailbox name by appending an <filename>_archive</filename> suffix to the
mailbox name. For example, if you run <command>archivemail</command> on a
mailbox called <filename>exsouthrock</filename>, the archive will be created
with the filename <filename>exsouthrock_archive.gz</filename>.
This default behavior can be overridden with command line options, choosing
a custom suffix, a prefix, or a completely custom name for the archive.
</para>
<para>
<command>archivemail</command> supports reading <acronym>IMAP</acronym>,
<acronym>Maildir</acronym>, <acronym>MH</acronym> and
<acronym>mbox</acronym>-format mailboxes, but always writes
<acronym>mbox</acronym>-format archives.
</para>
<para>
Messages that are flagged important are not archived or deleted unless
explicitly requested with the <option>--include-flagged</option> option.
Also, <command>archivemail</command> can be configured not to archive unread
mail, or to only archive messages larger than a specified size.
</para>
<para>
To archive an <acronym>IMAP</acronym>-format mailbox, use the format
<replaceable>imap://username:password@server/mailbox </replaceable> to specify
the mailbox.
<command>archivemail</command> will expand wildcards in
<acronym>IMAP</acronym> mailbox names according to
<citation><acronym>RFC</acronym> 3501</citation>, which says: <quote>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.</quote>
You can omit the password from the <acronym>URL</acronym>; use the
<option>--pwfile</option> option to make <command>archivemail</command> read
the password from a file, or alternatively just enter it upon request.
If the <option>--pwfile</option> option is set, <command>archivemail</command>
does not look for a password in the <acronym>URL</acronym>, and the colon is
not considered a delimiter.
Substitute <replaceable>imap</replaceable> with
<replaceable>imaps</replaceable>, and <command>archivemail</command> will
establish a secure <acronym>SSL</acronym> connection.
See below for more <acronym>IMAP</acronym> peculiarities.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<variablelist>
<varlistentry>
<term><option>-d <replaceable>NUM</replaceable></option></term>
<term><option>--days=<replaceable>NUM</replaceable></option></term>
<listitem><para>Archive messages older than <replaceable>NUM</replaceable>
days. The default is 180. This option is incompatible with the
<option>--date</option> option below.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-D <replaceable>DATE</replaceable></option></term>
<term><option>--date=<replaceable>DATE</replaceable></option></term>
<listitem><para>Archive messages older than <replaceable>DATE</replaceable>.
<replaceable>DATE</replaceable> can be a date string in ISO format (eg
<quote>2002-04-23</quote>), Internet format (<abbrev>eg</abbrev> <quote>23 Apr
2002</quote>) or Internet format with full month names (<abbrev>eg</abbrev>
<quote>23 April 2002</quote>). Two-digit years are not supported.
This option is incompatible with the <option>--days</option> option above.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-o <replaceable>PATH</replaceable></option></term>
<term><option>--output-dir=<replaceable>PATH</replaceable></option></term>
<listitem><para>Use the directory name <replaceable>PATH</replaceable> to
store the mailbox archives. The default is the same directory as the mailbox
to be read.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-P <replaceable>FILE</replaceable></option></term>
<term><option>--pwfile=<replaceable>FILE</replaceable></option></term>
<listitem><para>Read <acronym>IMAP</acronym> password from file
<replaceable>FILE</replaceable> instead of from the command line. Note
that this will probably not work if you are archiving folders from
more than one IMAP account.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-F <replaceable>STRING</replaceable></option></term>
<term><option>--filter-append=<replaceable>STRING</replaceable></option></term>
<listitem><para>Append <replaceable>STRING</replaceable> to the
<acronym>IMAP</acronym> filter string.
For <acronym>IMAP</acronym> wizards.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-p <replaceable>NAME</replaceable></option></term>
<term><option>--prefix=<replaceable>NAME</replaceable></option></term>
<listitem><para>Prefix <replaceable>NAME</replaceable> to the archive name.
<replaceable>NAME</replaceable> is expanded by the &python; function
<function>time.strftime()</function>, which means that you can specify special
directives in <replaceable>NAME</replaceable> to make an archive named after
the archive cut-off date.
See the discussion of the <option>--suffix</option> option for a list of valid
<function>strftime()</function> directives.
The default is not to add a prefix.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-s <replaceable>NAME</replaceable></option></term>
<term><option>--suffix=<replaceable>NAME</replaceable></option></term>
<listitem><para>
Use the suffix <replaceable>NAME</replaceable> to create the filename used for
archives. The default is <filename>_archive</filename>, unless a prefix is
specified.
</para>
<para>
Like a prefix, the suffix <replaceable>NAME</replaceable> is expanded by the
&python; function <function>time.strftime()</function> with the archive
cut-off date. <function>time.strftime()</function> understands the following
directives:
<variablelist id="strftime">
<varlistentry><term><code>%a</code></term>
<listitem><simpara>
Locale's abbreviated weekday name.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%A</code></term>
<listitem><simpara>
Locale's full weekday name.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%b</code></term>
<listitem><simpara>
Locale's abbreviated month name.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%B</code></term>
<listitem><simpara>
Locale's full month name.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%c</code></term>
<listitem><simpara>
Locale's appropriate date and time representation.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%d</code></term>
<listitem><simpara>
Day of the month as a decimal number [01,31].
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%H</code></term>
<listitem><simpara>
Hour (24-hour clock) as a decimal number [00,23].
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%I</code></term>
<listitem><simpara>
Hour (12-hour clock) as a decimal number [01,12].
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%j</code></term>
<listitem><simpara>
Day of the year as a decimal number [001,366].
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%m</code></term>
<listitem><simpara>
Month as a decimal number [01,12].
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%M</code></term>
<listitem><simpara>
Minute as a decimal number [00,59].
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%p</code></term>
<listitem><simpara>
Locale's equivalent of either AM or PM.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%S</code></term>
<listitem><simpara>
Second as a decimal number [00,61]. (1)
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%U</code></term>
<listitem><simpara>
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.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%w</code></term>
<listitem><simpara>
Weekday as a decimal number [0(Sunday),6].
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%W</code></term>
<listitem><simpara>
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.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%x</code></term>
<listitem><simpara>
Locale's appropriate date representation.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%X</code></term>
<listitem><simpara>
Locale's appropriate time representation.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%y</code></term>
<listitem><simpara>
Year without century as a decimal number [00,99].
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%Y</code></term>
<listitem><simpara>
Year with century as a decimal number.
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%Z</code></term>
<listitem><simpara>
Time zone name (or by no characters if no time zone exists).
</simpara></listitem>
</varlistentry>
<varlistentry><term><code>%%</code></term>
<listitem><simpara>
A literal <quote>%</quote> character.
</simpara></listitem>
</varlistentry>
</variablelist>
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-a <replaceable>NAME</replaceable></option></term>
<term><option>--archive-name=<replaceable>NAME</replaceable></option></term>
<listitem><para>Use <replaceable>NAME</replaceable> as the archive name,
ignoring the name of the mailbox that is archived.
Like prefixes and suffixes, <replaceable>NAME</replaceable> is expanded by
<function>time.strftime()</function> with the archive cut-off date.
Because it hard-codes the archive name, this option cannot be used when
archiving multiple mailboxes.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-S <replaceable>NUM</replaceable></option></term>
<term><option>--size=<replaceable>NUM</replaceable></option></term>
<listitem><para>Only archive messages that are <replaceable>NUM</replaceable>
bytes or greater.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-n</option></term>
<term><option>--dry-run</option></term>
<listitem><para>
Don't 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.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-u</option></term>
<term><option>--preserve-unread</option></term>
<listitem><para>
Do not archive any messages that have not yet been read.
<command>archivemail</command> determines if a message in a
<acronym>mbox</acronym>-format or <acronym>MH</acronym>-format mailbox has
been read by looking at the <literal>Status</literal> header (if it exists).
If the status header is equal to <quote><literal>RO</literal></quote> or
<quote><literal>OR</literal></quote> then <command>archivemail</command>
assumes the message has been read.
<command>archivemail</command> determines if a <acronym>maildir</acronym>
message has been read by looking at the filename.
If the filename contains an <quote><literal>S</literal></quote> after
<filename>:2,</filename> then it assumes the message has been read.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--dont-mangle</option>
</term>
<listitem><para>
Do not mangle lines in message bodies beginning with
<quote><literal>From&nbsp;</literal></quote>.
When archiving a message from a mailbox not in <acronym>mbox</acronym>
format, by default <command>archivemail</command> mangles such lines by
prepending a <quote><literal>&gt;</literal></quote> to them, since mail user
agents might otherwise interpret these lines as message separators.
Messages from <acronym>mbox</acronym> folders are never mangled. See &mbox;
for more information.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--delete</option>
</term>
<listitem><para>
Delete rather than archive old mail. Use this option with caution!
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--copy</option>
</term>
<listitem><para>
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 <option>--delete</option> option, and mainly
useful for testing purposes.
Note that multiple passes will create duplicates, since messages are blindly
appended to an existing archive.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--all</option>
</term>
<listitem><para>
Archive all messages, without distinction.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--include-flagged</option>
</term>
<listitem><para>
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.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--no-compress</option>
</term>
<listitem><para>
Do not compress any archives.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--warn-duplicate</option>
</term>
<listitem><para>
Warn about duplicate <literal>Message-ID</literal>s that appear in the input
mailbox.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose</option></term>
<listitem><para>
Reports lots of extra debugging information about what is going on.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>--debug-imap=<replaceable>NUM</replaceable></option>
</term>
<listitem><para>
Set <acronym>IMAP</acronym> debugging level. This makes
<command>archivemail</command> dump its conversation with the
<acronym>IMAP</acronym> server and some internal <acronym>IMAP</acronym>
processing to <literal>stdout</literal>. Higher values for
<replaceable>NUM</replaceable> give more elaborate output. Set
<replaceable>NUM</replaceable> to 4 to see all exchanged
<acronym>IMAP</acronym> commands. (Actually, <replaceable>NUM</replaceable>
is just passed literally to <literal>imaplib.Debug</literal>.)
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-q</option></term>
<term><option>--quiet</option></term>
<listitem><para>
Turns on quiet mode. Do not print any statistics about how many messages were
archived. This should be used if you are running
<command>archivemail</command> from cron.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-V</option></term>
<term><option>--version</option></term>
<listitem><para>
Display the version of <command>archivemail</command> and exit.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-h</option></term>
<term><option>--help</option></term>
<listitem><para>
Display brief summary information about how to run
<command>archivemail</command>.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
<command>archivemail</command> requires &python; version 2.3 or later.
When reading an <acronym>mbox</acronym>-format mailbox,
<command>archivemail</command> will create a lockfile with the extension
<filename class="extension">.lock</filename> so that &procmail; will not
deliver to the mailbox while it is being processed. It will also create an
advisory lock on the mailbox using &lockf;. The archive is locked in the same
way when it is updated.
<command>archivemail</command> will also complain and abort if a 3rd-party
modifies the mailbox while it is being read.
</para>
<para>
<command>archivemail</command> will always attempt to preserve the last-access
and last-modify times of the input mailbox. Archive mailboxes are always
created with a mode of <literal>0600</literal>.
If <command>archivemail</command> finds a pre-existing archive mailbox it will
append rather than overwrite that archive.
<command>archivemail</command> will refuse to operate on mailboxes that are
symbolic links.
</para>
<para>
<command>archivemail</command> attempts to find the delivery date of a message
by looking for valid dates in the following headers, in order of precedence:
<literal>Delivery-date</literal>,
<literal>Received</literal>,
<literal>Resent-Date</literal> and
<literal>Date</literal>.
If it cannot find any valid date in these headers, it will use the
last-modified file timestamp on <acronym>MH</acronym> and
<acronym>Maildir</acronym> format mailboxes, or the date on the
<literal>From_</literal> line on <acronym>mbox</acronym>-format mailboxes.
</para>
<para>
When archiving mailboxes with leading dots in the name,
<command>archivemail</command> will strip the dots off the archive name, so
that the resulting archive file is not hidden.
This is not done if the <option>--prefix</option> or
<option>--archive-name</option> 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.
</para>
<para>
A conversion from other formats to &mbox; will silently overwrite existing
<literal>Status</literal> and <literal>X-Status</literal> message headers.
</para>
<refsect2>
<title><acronym>IMAP</acronym></title>
<para>
When <command>archivemail</command> processes an <acronym>IMAP</acronym>
folder, all messages in that folder will have their <literal>\Recent</literal>
flag unset, and they will probably not show up as <quote>new</quote> in your
user agent later on.
There is no way around this, it's just how <acronym>IMAP</acronym> works.
This does not apply, however, if you run <command>archivemail</command> with
the options <option>--dry-run</option> or <option>--copy</option>.
</para>
<para>
<command>archivemail</command> relies on server-side searches to determine the
messages that should be archived.
When matching message dates, <acronym>IMAP</acronym> servers refer to server
internal message dates, and these may differ from both delivery time of a
message and its <literal>Date</literal> header.
Also, there exist broken servers which do not implement server side searches.
</para>
<refsect3><title><acronym>IMAP</acronym> <acronym>URL</acronym>s</title>
<para>
<command>archivemail</command>'s <acronym>IMAP</acronym>
<acronym>URL</acronym> parser was written with the <acronym>RFC</acronym> 2882
(<citetitle>Internet Message Format</citetitle>) rules for the
<token>local-part</token> of email addresses in mind.
So, rather than enforcing an <acronym>URL</acronym>-style encoding of
non-<acronym>ascii</acronym> and reserved characters, it allows you to
double-quote the username and password.
If your username or password contains the delimiter characters
<quote>@</quote> or <quote>:</quote>, just quote it like this:
<replaceable>imap://"username@bogus.com":"password"@imap.bogus.com/mailbox</replaceable>.
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.
</para>
<para>
Similarly, there is no need to percent-encode non-<acronym>ascii</acronym>
characters in <acronym>IMAP</acronym> mailbox names.
As long as your locale is configured properly, <command>archivemail</command>
should handle these without problems.
Note, however, that due to limitations of the <acronym>IMAP</acronym>
protocol, non-<acronym>ascii</acronym> characters do not mix well with
wildcards in mailbox names.
</para>
<para>
<command>archivemail</command> tries to be smart when handling mailbox paths.
In particular, it will automatically add an <acronym>IMAP</acronym>
<literal>NAMESPACE</literal> prefix to the mailbox path if necessary; and if
you are archiving a subfolder, you can use the slash as a path separator
instead of the <acronym>IMAP</acronym> server's internal representation.
</para>
</refsect3>
</refsect2>
</refsect1>
<refsect1>
<title>Examples</title>
<informalexample>
<para>
To archive all messages in the mailbox <filename>debian-user</filename> that
are older than 180 days to a compressed mailbox called
<filename>debian-user_archive.gz</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail debian-user</userinput>
</screen>
</para>
</informalexample>
<informalexample>
<para>
To archive all messages in the mailbox <filename>debian-user</filename> that
are older than 180 days to a compressed mailbox called
<filename>debian-user_October_2001.gz</filename> (where the current month and
year is April, 2002) in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --suffix '_%B_%Y' debian-user</userinput>
</screen>
</para>
</informalexample>
<informalexample>
<para>
To archive all messages in the mailbox <filename>cm-melb</filename> that
are older than the first of January 2002 to a compressed mailbox called
<filename>cm-melb_archive.gz</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --date='1 Jan 2002' cm-melb</userinput>
</screen>
</para>
</informalexample>
<informalexample>
<para>
Exactly the same as the above example, using an <acronym>ISO</acronym> date
format instead:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --date=2002-01-01 cm-melb</userinput>
</screen>
</para>
</informalexample>
<informalexample>
<para>
To delete all messages in the mailbox <filename>spam</filename> that
are older than 30 days:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --delete --days=30 spam</userinput>
</screen>
</para>
</informalexample>
<informalexample>
<para>
To archive all read messages in the mailbox <filename>incoming</filename> that
are older than 180 days to a compressed mailbox called
<filename>incoming_archive.gz</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --preserve-unread incoming</userinput>
</screen>
</para>
</informalexample>
<informalexample>
<para>
To archive all messages in the mailbox <filename>received</filename> that
are older than 180 days to an uncompressed mailbox called
<filename>received_archive</filename> in the current directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail --no-compress received</userinput>
</screen>
</para>
</informalexample>
<informalexample>
<para>
To archive all mailboxes in the directory <filename>$HOME/Mail</filename>
that are older than 90 days to compressed mailboxes in the
<filename>$HOME/Mail/Archive</filename> directory:
<screen>
<prompt>bash$ </prompt><userinput>archivemail -d90 -o $HOME/Mail/Archive $HOME/Mail/*</userinput>
</screen>
</para>
</informalexample>
<informalexample>
<para>
To archive all mails older than 180 days from the given
<acronym>IMAP</acronym> <literal>INBOX</literal> to a compressed mailbox
<filename>INBOX_archive.gz</filename> in the
<filename>$HOME/Mail/Archive</filename> directory, quoting the password and
reading it from the environment variable <envar>PASSWORD</envar>:
</para>
<!-- i'm open to suggestions how to avoid making such a super-long line here. -->
<screen>
<prompt>bash$ </prompt><userinput>archivemail -o $HOME/Mail/Archive imaps://user:'"'$PASSWORD'"'@example.org/INBOX</userinput>
</screen>
<para>
Note the protected quotes.
</para>
</informalexample>
<informalexample>
<para>
To archive all mails older than 180 days in subfolders of <filename
class="directory">foo</filename> on the given <acronym>IMAP</acronym>
server to corresponding archives in the current working directory, reading the
password from the file <filename>~/imap-pass.txt</filename>:
</para>
<screen>
<prompt>bash$ </prompt><userinput>archivemail --pwfile=~/imap-pass.txt imaps://user@example.org/foo/*</userinput>
</screen>
</informalexample>
</refsect1>
<refsect1>
<title>Tips</title>
<para>
Probably the best way to run <command>archivemail</command> is from your
&crontab; file, using the <option>--quiet</option> option.
Don't forget to try the <option>--dry-run</option> and perhaps the
<option>--copy</option> option for non-destructive testing.
</para>
</refsect1>
<refsect1>
<title>Exit Status</title>
<simpara>Normally the exit status is 0. Nonzero indicates an unexpected error.
</simpara>
</refsect1>
<refsect1>
<title>Bugs</title>
<simpara>
If an <acronym>IMAP</acronym> mailbox path contains slashes, the archive
filename will be derived from the basename of the mailbox.
If the server's folder separator differs from the Unix slash and is used in
the <acronym>IMAP</acronym> <acronym>URL</acronym>, however, the whole path
will be considered the basename of the mailbox.
<abbrev>E.g.</abbrev> the two <acronym>URL</acronym>s
<userinput>imap://user@example.com/folder/subfolder</userinput> and
<userinput>imap://user@example.com/folder.subfolder</userinput> will be
archived in <filename>subfolder_archive.gz</filename> and
<filename>folder.subfolder_archive.gz</filename>, respectively, although they
might refer to the same <acronym>IMAP</acronym> mailbox.
</simpara>
<simpara>
<command>archivemail</command> does not support reading
<acronym>MMDF</acronym> or <acronym>Babyl</acronym>-format mailboxes. In fact,
it will probably think it is reading an <acronym>mbox</acronym>-format mailbox
and cause all sorts of problems.
</simpara>
<simpara>
<command>archivemail</command> is still too slow, but if you are running from
&crontab; you won't care. Archiving <acronym>maildir</acronym>-format
mailboxes should be a lot quicker than <acronym>mbox</acronym>-format
mailboxes since it is less painful for the original mailbox to be
reconstructed after selective message removal.
</simpara>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member>&mbox;</member>
<member>&crontab;</member>
<member>&python;</member>
<member>&procmail;</member>
</simplelist>
</refsect1>
<refsect1>
<title><acronym>Url</acronym></title>
<simpara>The <command>archivemail</command> home page is currently hosted at
<ulink type="http" url="http://archivemail.sourceforge.net">sourceforge</ulink>
</simpara>
</refsect1>
<refsect1>
<title>Author</title>
<simpara> This manual page was written by Paul Rodger &lt;paul at paulrodger
dot com&gt;. Updated and supplemented by Nikolaus Schulz
<email>microschulz@web.de</email></simpara>
</refsect1>
</refentry>

10
db2html.xsl Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl"/>
<xsl:param name="html.stylesheet">manpage.css</xsl:param>
<xsl:template name="user.header.content">
<h1>archivemail</h1>
<hr/>
</xsl:template>
</xsl:stylesheet>

29
db2man.xsl Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl"/>
<!-- Use .TP list for the variablelist describing the strtime() directives. -->
<!-- This hack aligns the indented paragraphs horizontally with their -->
<!-- labels. -->
<xsl:template match="variablelist[attribute::id='strftime']/varlistentry">
<xsl:text>.TP&#10;</xsl:text>
<xsl:for-each select="term">
<xsl:variable name="content">
<xsl:apply-templates/>
</xsl:variable>
<xsl:value-of select="normalize-space($content)"/>
<xsl:choose>
<xsl:when test="position() = last()"/> <!-- do nothing -->
<xsl:otherwise>
<!-- * if we have multiple terms in the same varlistentry, generate -->
<!-- * a separator (", " by default) -->
<xsl:value-of select="$variablelist.term.separator"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

192
index.html Normal file
View File

@ -0,0 +1,192 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type"
content="text/html;charset=us-ascii">
<title>archivemail &ndash; a tool for archiving and compressing old email</title>
<link title="archivemail style" rel=stylesheet href="style.css"
type="text/css">
<style type="text/css">
/*<![CDATA[*/
.command {font-weight: bold;}
.example {
/*background-color: #e0e0e0;*/
padding: 0 2em;
}
#status {
float: right;
width: 10em
margin-left: 4em;
margin-top: 1.3em;
padding: 3ex;
border: 1px solid #777777;
line-height: 160%;
}
/*span.mail {text-decoration: underline;}*/
/*]]>*/
</style>
</head>
<body>
<h1>archivemail</h1>
<hr>
<div id="status">
<strong>Latest version: 0.9.0</strong><br>
Released on 2011-07-09
</div>
<h2>What is it?</h2>
<p>
<span class="command">archivemail</span> is a tool for archiving and compressing
old email in mailboxes.
It moves messages older than the specified number of
days to a separate <a title="mbox(5) man page"
href="http://www.qmail.org/man/man5/mbox.html">mbox format</a> mailbox that is
compressed with <span class="command">gzip</span>.
It can also just delete old email rather than archive it.
<h2>What can it do for me?</h2>
<p>
Maybe some of your mailboxes are quite large (eg, over 10,000 messages) and
they are taking a while to load in your mail reader. Perhaps they are taking
up too much space on your disk. Archiving old messages to a separate,
compressed mailbox will mean:
<ol>
<li>Your mail reader will get a huge performance boost loading and reading
your mail.
<li>You will be taking up less disk space, since old mail will be compressed.
(Mail usually compresses quite nicely.)
<li>You won't be confronted with semi-obsolete mail all the time.
</ol>
<p>
You can also use <span class="command">archivemail</span> as a simple backup
tool.
<h2>Features overview</h2>
<ul>
<li>Supports archiving
<a title="about IMAP" href="http://www.imap.org/">IMAP</a>,
<a title="mbox(5) man page" href="http://www.qmail.org/man/man5/mbox.html">mbox</a>,
<a title="MH FAQ" href="http://www.faqs.org/faqs/mail/mh-faq/">MH</a> and
<a title="maildir(5) man page"
href="http://www.qmail.org/man/man5/maildir.html">Maildir</a> format
mailboxes.
<li>Old mail can be either archived or just deleted.
<li>The age in days that is considered old is configurable &ndash; it defaults
to 180 days.
You can also set an absolute limit date.
<li>Messages that are flagged important are not archived or deleted unless
explicitely requested.
<!--<li>You can specify an option so that unread mail is never archived.-->
<li>Can be configured to preserve unread mail.
<li>Can be configured to only archive messages over a given byte size.
<li>Stores the compressed archive mailboxes in a directory of
your choice, with an extension of your choice.
<li>Easy read-only testing, not touching your valuable data.
<li>Supports IMAPS/SSL.
<li>When archiving IMAP mailboxes, the message selection can be refined by
extending the underlying IMAP <code>SEARCH</code> command with arbitrary
search keys (you will have to cope with the raw IMAP protocol, though).
</ul>
<h2>Documentation</h2>
<p>
The <a href="manpage.html">archivemail manpage</a> is the primary documentation
for <span class="command">archivemail</span>.
To see what has changed in the latest version, check the <a
href="RELNOTES">release notes</a>.
If you want to have a closer look at the current development status, here's the
<a title="changelog in git HEAD" href=
"http://archivemail.git.sourceforge.net/git/gitweb.cgi?p=archivemail/archivemail;a=blob;f=CHANGELOG;hb=HEAD">
CHANGELOG</a> and the <a title="TODO list in git HEAD" href=
"http://archivemail.git.sourceforge.net/git/gitweb.cgi?p=archivemail/archivemail;a=blob;f=TODO;hb=HEAD">
TODO list</a>, fresh from the repository.
<h2>Where can I get it?</h2>
<p>
You can grab the latest version of <span class="command">archivemail</span>
directly from the <a
href="http://sourceforge.net/project/showfiles.php?group_id=49630">archivemail
download area</a> at Sourceforge.
There should be up-to-date binary RPM packages at the
<a href="http://software.opensuse.org/download/server:/mail/">OpenSUSE build
service</a> for SUSE Linux and Fedora Core.
Also, many Linux distributions provide packages; e.g. there is a
<a href="http://packages.debian.org/unstable/archivemail">Debian
package</a>.
<p>
<span class="command">archivemail</span> is written in Python, and hacking it is
easy and fun; you can check out the source from the git repository with
the following command:
<div class="example">
<kbd>git clone git://archivemail.git.sourceforge.net/gitroot/archivemail/archivemail</kbd>
</div>
<p>
See also the short <a href="http://sourceforge.net/scm/?type=git&amp;group_id=49630">
introduction to git access</a> at sourceforge.
<!-- 2007-11-06: this site has problems, and I cannot read the mentioned article.
<h3>Articles</h3>
<p>
Emmanuel Seyman wrote an
<a href="http://muttfr.org/gen.php3/2002/11/20/108,1,0,0,1.php3">article
about archivemail</a> for <a href="http://www.muttfr.org/">muttfr.org</a>, a
French website about <a href="http://www.mutt.org/">mutt</a>.
-->
<h2>Getting involved</h2>
<ul>
<li>Visit the <a
href="http://sourceforge.net/tracker/?group_id=49630">archivemail
tracker</a> to browse and/or submit bug reports and feature requests.
<li>You can subscribe to the <a
href="http://lists.sourceforge.net/lists/listinfo/archivemail-user">archivemail-user
mailing list</a>.
This is a low traffic, subscribers-only list.
<li>Check out the <a href="http://sourceforge.net/projects/archivemail/">project page
for archivemail</a> at Sourceforge for a general overview.
</ul>
<h2>Requirements</h2>
<p>
<span class="command">archivemail</span> requires Python 2.3 or newer.
It also uses some optional python modules, but these should be pretty much
standard; if you get an ImportError nonetheless, please
<a title="jump to the archivemail tracker"
href="http://sourceforge.net/tracker/?group_id=49630">report it</a>, thanks.
<h2>License</h2>
<p>
This software is licensed under the terms of the
<a href="http://www.gnu.org/licenses/licenses.html#GPL">GNU GPL</a>, either
version 2 of the license, or any later version.
<h2>Credits</h2>
<p>
<span class="command">archivemail</span> was written by Paul Rodger
<code>&lt;paul <em>at</em> paulrodger <em>dot</em>
com&gt;</code>
and is currently maintained by Peter Poeml <code>&lt;poeml
<em>at</em> suse <em>dot</em> de&gt;</code>, Nikolaus Schulz <code><a href=
"mailto:microschulz@web.de">&lt;microschulz@web.de&gt;</a></code>
and Brandon Knitter.
<hr>
<p>
<!-- sourceforge logo start -->
<a href="http://sourceforge.net">
<!-- white: -->
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=49630&amp;type=2"
width="125" height="37"
alt="SourceForge.net Logo">
<!-- blue:
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=49630&amp;type=4"
width="125" height="37"
alt="SourceForge.net Logo">
-->
</a>
<!-- sourceforge logo end -->
</body>
</html>

15
manpage.css Normal file
View File

@ -0,0 +1,15 @@
@import "style.css";
h2 {
font-variant: small-caps;
font-size: 170%;
}
.informalexample {
margin-bottom: 1.2em;
}
div.informalexample .screen {
margin-left: 2ex;
}
a#strftime + dl dt { float: left; margin: 0.3ex 0; width: 1.5em; }
a#strftime + dl dd { float: left; margin: 0.3ex 0; margin-left: 1.2em; width: 90%; }
dt { clear: left; }

View File

@ -15,16 +15,19 @@ Your version of python is: %s""" % sys.version
print too_old_error
sys.exit(1)
check_python_version() # define & run this early - 'distutils.core' is new
# define & run this early - 'distutils.core' requires Python >= 2.0
check_python_version()
from distutils.core import setup
setup(name="archivemail",
version="0.6.0",
version="0.9.0",
description="archive and compress old email",
license="GNU GPL",
url="http://archivemail.sourceforge.net/",
author="Paul Rodger",
author_email="paul@paulrodger.com",
maintainer="Nikolaus Schulz, Peter Poeml",
maintainer_email="nikosch@users.sourceforge.net, poeml@users.sourceforge.net",
scripts=["archivemail"],
data_files=[("man/man1", ["archivemail.1"])],
data_files=[("share/man/man1", ["archivemail.1"])],
)

49
style.css Normal file
View File

@ -0,0 +1,49 @@
body {
padding: 2%;
line-height: 130%;
margin: 0;
/*color: #036;*/
}
h1 {
font-size: 220%;
font-weight: bold;
padding: 0 0 0.4em 0.1em;
/*margin: 0 0 0.5em 0; */
margin: 0;
/*border-bottom: 2px solid black;*/
}
hr {
border: 1px #b8b8b8 solid;
}
h1 + hr {
margin-top: 0;
margin-bottom: 1.7em;
}
h2 {
margin: 1em 0 0.8em 0;
padding: 0;
font-size: 150%;
}
img {border: none;}
a {
text-decoration: underline;
}
a:link {
/*color: #0073c7;*/
color: blue;
background-color: inherit;
}
a:visited {
/*color: #5A88B5;*/
color: #844084;
background-color: inherit;
}
/*
a:hover,
a:active {
color: #0073c7;
background-color: #f0f0f0;
}
*/

1771
test_archivemail Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff