Gmail logger - log your google account in 2023

Gmail logger - log your google account in 2023

I found this GitHub repository with a Python script that helps you log metadata about your Gmail inbox.

I read the manual and replicate it.


Clone the repository with this command:

git clone [email protected]:mddub/gmail-logger.git

Add a file called , which looks like this.

email = '[email protected]'
password = 'your_app_password'

Google app password

You probably have a Google account with 2-step verification, so you need to create a new app password for this.

  • Go to your Google account

  • Open the Security tab and find a block "Signing in to Google."

  • Click on the second option, "App passwords."

  • On the next page, you need to "Select the app and device for which you want to generate the app password." and click Generate password button

  • You will see a new password that you have to copy and add to the file. If you close this window, you will not see this password anymore, so you need to generate another one.

Python environment

Make sure you have "pip" and "virtualenv" installed on your machine.

You need to set up a virtualenv, activate it, and install the requirements:

virtualenv venv
. venv/bin/activate
pip install -r requirements.txt

Once you have done it, please test it out:


To schedule it to run regularly you can use crontab which schedules it every hour:

0 * * * * cd /path/to/log/to; /path/to/gmail-logger/venv/bin/python /path/to/gmail-logger/ >/dev/null

Reporting Output

If you were to run it hourly, inbox_count.log would look something like this:

1664363664	2022-09-28 11:14:24	48
1664367264	2022-04-28 12:14:24	49

Every hour, a JSON file named something like 2022-09-28_11.14.24.json would be produced:

    "date": "Mon, 28 Mar 2022 11:14:24 +0900",
    "thread_id": "1497103965428563028",
    "unread": false,
    "from": [
      "Donald Trump <[email protected]>"
    "subject": "Hi Rus, how are you doing?"

Related articles

Ruslan Osipov
Written by author: Ruslan Osipov