Skip to main content

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

  1. Create a Google Cloud project and enable the Gmail API
  2. Create an OAuth2 Client ID (type Desktop)
  3. Copy .env.example to .env and fill in GMAIL_CLIENT_ID and GMAIL_CLIENT_SECRET
  4. 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.4.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mes_courriels-0.0.4-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file mes_courriels-0.0.4.tar.gz.

File metadata

  • Download URL: mes_courriels-0.0.4.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mes_courriels-0.0.4.tar.gz
Algorithm Hash digest
SHA256 0f5caa4ed46c1705bc62b954e9e2c3a177a3c9df9fb74a094200741aa32eeacc
MD5 70c1b109a7c9a07aff1acbd57e6c5443
BLAKE2b-256 88fed74b8cf847b8beae4af1e584fcc9836da2ab8cd36e9df0449f8fc5aeae81

See more details on using hashes here.

File details

Details for the file mes_courriels-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mes_courriels-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mes_courriels-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d98de0c5b36dc6fe7bb7b5cc13c95ea62fc41b1cc693f361f0542f79b72b12f1
MD5 25bf4f8dddd3a67e4e9c03119a7a5f00
BLAKE2b-256 764df7b4b5e84c8506860f1a0e0c45b0e482ead96a70ab01293bb5fe4a39ec98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page