A desktop app for managing emails in your Gmail account. It enables you to perform common operations on your emails such as marking them read/unread, moving them to spam/trash, etc.
- Follow steps 1-5 from the official Google Workspace guide to create your access credentials.
- If you're using an OAuth client ID for authentication, exercise caution while choosing the scopes as they define the varying level of access this app will have to your mailbox.
- For the purpose of reading emails and moving them around (spam/trash/etc), the following scopes are required:
"https://www.googleapis.com/auth/gmail.labels", "https://mail.google.com/", "https://www.googleapis.com/auth/gmail.modify", "https://www.googleapis.com/auth/gmail.readonly"
- Once the credentials are created, download the
credentials.json
file.
- Clone the repository and navigate into it:
git clone <repository_url> cd <repository_folder>
- Place the
credentials.json
file at the root of the folder. - Create a virtual environment and activate it.
python -m venv <env_name> source <env_name>/bin/activate
- Install the requirements
pip install -r requirements.txt
- Configure the
rules.json
file to define the criteria for selecting emails and the actions you intend to perform on them. Below is a sample configuration:
[
{
"conditions": {
"apply_predicate": "all",
"condition_items": [
{
"field": "from",
"predicate": "contains",
"value": "[email protected]"
},
{
"field": "subject",
"predicate": "contains",
"value": "Weekly Update"
}
]
},
"actions": [
{
"field": "mark_as_read",
},
{
"field": "move_message",
"predicate": "TRASH"
}
]
}
]
- Once the config is prepared, run the main program:
python main.py
- If you're running the program for the first time, you will be asked to allow the permissions the app requires.
- Upon successful authorization, a
token.json
file will be created. If you need to update the scopes, delete the existingtoken.json
file and run the program again.