Parse your "gmail takeout file" or any another .mbox
file and indexing mail messages into MongoDB.
After that you can use some aggregation functions for insights or analytics your inbox
- Go here and download your Gmail mailbox, depending on the amount of emails you have accumulated this might take a while. The downloaded archive is in the mbox format.
- Build importer from source or download release
$ git clone [email protected]:Rpsl/mboximporter.git && cd ./mboximporter
$ go mod download
$ go build -o mbox-importer ./
Run MongoDB, you can use docker-compose for starting mongodb and web-view panel:
docker-compose up
Parse the messages:
mbox-importer -init -filename ~/path/to/your/mail.mbox
Connection to the MongoDB instance:
mongo -u root -p example --authenticationDatabase admin
> use mbox-importer
switched to db mbox-importer
And exec aggregation functions.
> db.mails.aggregate([
{ $match: { labels: { $in: ['inbox'] } } },
{ $unwind: "$sender" },
{ $group: {_id: "$sender", total: {$sum : 1} } },
{ $sort: {"total": -1 } }
]);
Usage of ./mbox-importer:
-body
Parse and insert body of the emails
-database string
The Database name to use in MongoDB (default "mbox-importer")
-filename string
Name of the filename to import
-headers
Parse and insert all headers of the emails
-init
Drop if exist collection and create fresh
-mongo string
The Mongo URI to connect to MongoDB (default "root:[email protected]")
- Repair parse body
- Extract examples (aggregate functions) to the personal classes and execute from cli
- Add
--report
option for executing the aggregates and generate report files