A Python mail connector library
Project description
mail_connector
Gmail connector for Python — read, modify, and organize emails via OAuth2.
Installation
pip install mes-courriels
Setup
- Create a Google Cloud project and enable the Gmail API
- Create an OAuth2 Client ID (type Desktop)
- Copy
.env.exampleto.envand fill inGMAIL_CLIENT_IDandGMAIL_CLIENT_SECRET - Run the auth script to get a refresh token:
uv run python scripts/auth.py
Usage
from mail_connector import GmailConnector
gmail = GmailConnector()
gmail.list_labels()
gmail.list_messages(query="from:alice@example.com")
gmail.get_message("msg_id")
gmail.mark_as_read("msg_id")
gmail.mark_as_unread("msg_id")
gmail.archive("msg_id")
gmail.trash("msg_id")
gmail.modify_message("msg_id", add_label_ids=["STARRED"])
CLI
mes-courriels alice@example.com # 10 derniers messages
mes-courriels alice@example.com -n 3 # les 3 derniers
Development
- Python >= 3.12, uv
uv sync
uv run pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mes_courriels-0.0.2.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mes_courriels-0.0.2.tar.gz.
File metadata
- Download URL: mes_courriels-0.0.2.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf15395ce65c8e3878b8f10c962c177a8ae2df18b003e0b07e8cd3f9bc85a94f
|
|
| MD5 |
cf0aa12a31668a4e80738e6f75ff6ea0
|
|
| BLAKE2b-256 |
7ef932a3cc1a2e7f0bdb413f1e15ebf77e15af1fb24a1b7ad69d73a9e0f41d53
|
File details
Details for the file mes_courriels-0.0.2-py3-none-any.whl.
File metadata
- Download URL: mes_courriels-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
109053a5ffe961763b31067509584c5b30c33469272c96f755bd95dbb7f2eba7
|
|
| MD5 |
805785fd995d3ed404d913e83391d129
|
|
| BLAKE2b-256 |
bbbc3d66f7b1de83f8429e887637796ab0d206c9ef8c5f676eb249833573a96e
|