Broobles » eml2mbox  

eml2mbox - A Ruby eml to mbox converter
This is a platform independant Ruby script for converting multiple eml files into a single mbox (Unix Mailbox) file whose format is described here. Generated files can be imported to all email clients under Windows, Linux, Mac, etc that support the mbox format (most of them do). If you find any problems importing generated files feel free to contact me (see the bottom of this page for details).
- If you are running the Windows OS and don't feel like installing Ruby, you can convert your emls to mbox with IMAPSize which has a built in eml2mbox (and also a mbox2eml) converter.
- If you have a Fastmail.FM account you can use this script to convert your archives to mbox format. You'll have to unzip the archive(s), then proceed as described below. If you don't have an account, you should definetelly open one - the basic account is free.

Script usage
  • You need to have Ruby installed. If you don't have it you can download it from the Ruby homepage.
  • Usage: [ruby] eml2mbox.rb [-c][-l][-s][-yz] [emlpath [trgtmbox]]
  • The script is run by typing 'ruby eml2mbox.rb' (with or without parameters - see below) in the directory where the script is located. Depending on your installation, you might be able to invoke it by only typing 'eml2mbox.rb
  • This script takes two optional parameters. First one (emlpath) is the directory where your eml files are located. If you don't specify it the current dir is assumed. Second parameter (trgtmbox) is the name of the mbox file you want to create. It is recognized as such only if you specify the first param. If omitted, a file 'archive.mbox' will be created in the folder where your eml files are located. Filenames (paths) with spaces are not allowed as parameters! However, they are allowed as eml filenames. Relative pahtnames are allowed.
  • Switches:
    • -c Remove CRs (^M) appearing at end of lines (Unix)
    • -l Remove LFs appearing at beggining of lines (Mac) - not tested
    • -s Don't use standard mbox postmark formatting (for From_ line). This will force the use of original From and Date found in mail headers. Not recommended, unless you really have problems importing emls
    • -yz Use this to change the order of the year and timezone in the date part of the From_ line from the default [timezone][year] to [year][timezone]. You might want to use this if your email client doesn't like the default order
  • If the specified mbox file already exists, you will have an option to append new mails to it, overwrite it or cancel the action.
  • Open your email client and import the mbox file
  • The original *.eml files are not touched, so feel free to experiment...

Paths here are Win specific, but description applies for Unix systems too.

  • ruby eml2mbox.rb - Both eml files and the archive are located in the current dir
  • ruby eml2mbox.rb c:\fm\archive\ebay - Both eml files and the archive (saved as archive.mbox) are located in the specified folder
  • ruby eml2mbox.rb c:\fm\archive\ebay c:\fm\mbox\ebay.mbox - emls in the first folder, archive saved to the specified file
  • ruby eml2mbox.rb c:\fm\archive\ebay ebay.mbox - emls in the specified folder, archive saved to c:\fm\archive\ebay\ebay.mbox

Currently there are no outstanding issues. If you find any feel free to report them.

For any bugs, comments or suggestions you can use the forum or send an email to eml2mbox AT broobles DOT com

  Copyright © 2002-2007 Broobles