Written by: Maciej GrajcarekJuly 1, 2008
If for some reason you would like to copy your messages from Thunderbird to a MySQL database, here you can find a simple PHP script which will do it for you! All you have to do is to set some variables in the php class and create a proper database table. Let’s start with the class.
var $file_name = 'some_mbox_file'; var $file_path = '/path/to/file/'; var $db_user = 'user'; var $db_password = 'pass'; var $db_host = 'localhost'; var $db_name = 'mbox';
$file_name is the name of the thunderbird mbox file and $file_path points to the folder it is located (deafult path in Windows looks sth like this: C:\\Documents and Settings\\%user%\\Application Data\\Thunderbird\\Profiles).
You should also define the database connection variables.
Next thing is to create a database table:
CREATE TABLE `messages` ( `id` int(10) unsigned NOT NULL auto_increment, `from` varchar(255) collate latin1_general_ci NOT NULL, `to` varchar(255) collate latin1_general_ci NOT NULL, `subject` varchar(255) collate latin1_general_ci NOT NULL, `date` varchar(255) collate latin1_general_ci NOT NULL, `message` text collate latin1_general_ci NOT NULL, `received_ip` varchar(15) collate latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
As you can see, this script will read: from, to, subject, date, received_ip and message fields for each of messages. It will not copy attachments!
It supports also processing of big files. We have used it to parse files bigger than 3GB.