example community package
Project description
Swarmauri Tool Gmail
Tools for sending and reading Gmail messages via Google Workspace service-account delegation. Provides GmailSendTool and GmailReadTool wrappers around the Gmail REST API.
Features
GmailSendToolsends HTML emails to one or more recipients.GmailReadToolfetches messages matching a Gmail search query and formats key headers.- Both tools authenticate with
googleapiclientusing a service account JSON file and delegated user email.
Prerequisites
- Python 3.10 or newer.
- Google Cloud service account with Gmail API enabled and domain-wide delegation to the target user.
- Credentials JSON file with the
https://www.googleapis.com/auth/gmail.sendand/orhttps://www.googleapis.com/auth/gmail.readonlyscopes. - Install
google-api-python-clientandgoogle-auth(pulled in automatically).
Installation
# pip
pip install swarmauri_tool_gmail
# poetry
poetry add swarmauri_tool_gmail
# uv (pyproject-based projects)
uv add swarmauri_tool_gmail
Sending Email
from swarmauri_tool_gmail import GmailSendTool
send_tool = GmailSendTool(
credentials_path="service-account.json",
sender_email="user@yourdomain.com",
)
result = send_tool(
recipients="recipient@example.com",
subject="Test Email",
htmlMsg="<p>Hello, this is a test email!</p>",
)
print(result)
Reading Email
from swarmauri_tool_gmail import GmailReadTool
read_tool = GmailReadTool(
credentials_path="service-account.json",
sender_email="user@yourdomain.com",
)
result = read_tool(query="is:unread", max_results=5)
print(result["gmail_messages"])
Tips
- Ensure the service account has been granted domain-wide delegation and that the Gmail API is enabled in Google Cloud console.
- Store credentials securely (Secrets Manager, Vault) and inject the file path via environment variables.
- When sending to multiple recipients, supply a comma-separated string (Gmail handles the formatting).
- For message bodies beyond simple HTML, extend the tool to add attachments or alternative MIME parts.
Want to help?
If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 swarmauri_tool_gmail-0.9.2.tar.gz.
File metadata
- Download URL: swarmauri_tool_gmail-0.9.2.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add45e38e82129afc9e5118ef8c5e36b041e46823db853e7d1d40a89a0ea5fa0
|
|
| MD5 |
c2c3ea4227a6782019dac35d27a39f91
|
|
| BLAKE2b-256 |
36fc98a2fcafd65cbeb70bf0d19b445c1a0cddc91e6a81925b2b51d10d70dc84
|
File details
Details for the file swarmauri_tool_gmail-0.9.2-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_gmail-0.9.2-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1232fa4637f3b8536149952d72bb79654f0a89ee70aa4a59e03daa35bfd67f8c
|
|
| MD5 |
bbb2872e1424f17bfc228b27080f98b3
|
|
| BLAKE2b-256 |
b9a06f978a447ca33713184b6b49cd390155dd741c2aa4ff5f12d9d09c5cc6b0
|