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
mes-courriels alice@example.com -w # surveiller en continu (60s)
mes-courriels alice@example.com -w -i 30 # surveiller toutes les 30s
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.5.tar.gz
(10.3 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.5.tar.gz.
File metadata
- Download URL: mes_courriels-0.0.5.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a21c7a92449baff42e354acdb1ba50c1f8d865443c0781b38820809e90aafac
|
|
| MD5 |
e9b0a7f7c94591b9849f28f8dfc7663e
|
|
| BLAKE2b-256 |
17a83edcafd5c41fcc6a47f8e4d64e75a58503af807d7df7ee2f909a2bbb2073
|
File details
Details for the file mes_courriels-0.0.5-py3-none-any.whl.
File metadata
- Download URL: mes_courriels-0.0.5-py3-none-any.whl
- Upload date:
- Size: 6.6 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 |
901565b00901b8119a37699e5483462e8d72947aaeb1ad74c2e803333c3f2de0
|
|
| MD5 |
f7fa3ecdb0ceb1219a598b6c47dbf5f1
|
|
| BLAKE2b-256 |
39e3243ac7f03459ec39c3fd3cec05fb002bfd6e94195f1643d98f7866dd7059
|