md2mb#

Convert maildir to mbox.

Uses Python’s included mailbox library to convert mail archives from maildir [http://en.wikipedia.org/wiki/Maildir] to mbox [http://en.wikipedia.org/wiki/Mbox] format, including subfolders.

See http://docs.python.org/library/mailbox.html#mailbox.Mailbox for full documentation on this library.

To run, save as md2mb.py and run:

$ python md2mb.py [maildir_path] [mbox_filename]

[maildir_path] should be the the path to the actual maildir (containing new, cur, tmp, and the subfolders, which are hidden directories with names like .subfolde.subsubfolder.subsubsbfolder);

[mbox_filename] will be newly created, as well as a [mbox_filename].sbd the directory.

Classes#

UTF8Mbox

Subclass of mbox that uses utf-8 for message encoding.

Functions#

custom_message_from_file(file)

Convert file content to email message.

maildir2mailbox(maildirname, mboxfilename)

Convert maildir to mbox format.

Module Contents#

md2mb.custom_message_from_file(file)#

Convert file content to email message.

Parameters:

file (io.BytesIO)

Return type:

email.message.Message

class md2mb.UTF8Mbox(path, factory=None, create=True)#

Bases: mailbox.mbox

Subclass of mbox that uses utf-8 for message encoding.

md2mb.maildir2mailbox(maildirname, mboxfilename)#

Convert maildir to mbox format.

Parameters:
  • maildirname (str | pathlib.Path)

  • mboxfilename (str | pathlib.Path)

Return type:

None