Cover image for How to get Email Stats from Thunderbird

How to get Email Stats from Thunderbird

devmount profile image Andreas Updated on ・3 min read

The time had come to fix something I didn’t know I was missing before: a visual overview of my emails meta data.

I’m a fan of data visualization. I love reading info-graphics, analyzing patterns in scatter charts or guessing possible reasons for flashy spots in a heat map. I found the visualization of my work to be a great motivation to make progress and to try even harder. Examples are the contributions graph on my GitHub profile or the overview of views and watch time on YouTube Studio. Visuals and numbers can be very powerful when they present the information that matters in an easily understandable way.

So I thought about using this visual motivation for one of the more annoying activities in my working life: Emails. I have to read them, I have to write them. I have to understand the point of the sender and have to answer accordingly. This is work that is often not valued. Especially not from myself.

I recently stumbled upon ‘The Personal Analytics of My Life’ by Stephen Wolfram. I was impressed (and maybe a little terrified) how much data you can collect from yourself — I mean he even tracked his keystrokes for years! But the analysis of his emails inspired me to do something similar or at least to get to know, how many emails I ever received and sent. Since I’m using Mozilla Thunderbird as email client and there is currently no analytics add-on for the latest version available, I had to build something my own.

This is how I created a tool to serve statistics about my emails:

The format

First, I had to find a way to get to my emails data at all. I searched for the files, Thunderbird stores my emails in. On Windows, it’s usually the following:


It turned out, that my emails were stored in the mbox format, one file per IMAP directory. After looking into these files, I decided to switch my account to the maildir format (storing one file per email), which was easier to handle when processing the email files. Also, maildir seems to be the preferred format today, because of its scalability and performant searchability.

The data retrieval

Now that I knew, where and how my email data was stored, I wrote a Python script to go through all email files, retrieve the data (currently just time and number of emails) and store it in JSON format. Despite redundancy I decided to store different evaluations in different JSON files for others being able to import only the needed or wanted files.

The visualization

With these JSON files and the help of Vue.js and Chart.js I built a simple frontend to present the resulting numbers and charts:

Thunderbird Email Stats frontend

Current frontend of Thunderbird Email Stats

As you can see, there are currently just some basic numbers and a few charts to display the total number of emails per year, per month, per time of day and per day of week — divided into outgoing and incoming emails. But even this simple visualization of my email data is enough to show, how the effort of managing emails constantly increases over the last years, where my productive hours are and that I lost two of almost sixteen years of email data I had…

Next steps

I’d like to extend this tool with some additional charts:

  • a bar chart showing the number of emails per month of year (indicating a possible dependency of emails to seasons of the year)
  • a scatter plot or heat map showing each single day colored according to the corresponding number of emails on this day
  • show an evaluation of the last week/month/year compared to the previous period

You can find this project on GitHub. I’d be glad if it’s useful for someone else. Maybe you have suggestions for additional analytics about your emails you would be interested in? Let’s discuss that in the comments below.

Originally published: 4th October 2019 on Medium

Posted on by:

devmount profile



creator. developer. consultant. freelancer. husband. dad². guitarero. climber. javascript. php. python. css.


markdown guide

Hi there! This is soooo good. I have installed this in one of my machines with alot of email accounts in my thunderbird. What I want for this one though is that, it can have the numbers of emails that is still unread and that it will separate each email addresses that I have inserted in the config file. I did some modification but cannot seem to do what I wanted it to do. If you can help me it for some $ or even for free, it would really help me alot. Thank you!


I'm glad, this tool is useful for you! Please create an issue on Github with a detailed description of what you want to achieve, it would be my pleasure to help you out for free - however, you can nevertheless support me here or here with any amount if you want 😊


Hi, I have made a new issue on github. Will be waiting for the update <3 Will consider sending some love $$ after that feature will be added. Thank you Andreas!

Thank You 👍🏻! I splitted the request into two issues. We can discuss them directly on Github!