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.
Metadata
Release files for swarmauri_tool_gmail 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swarmauri_tool_gmail-0.10.0.tar.gz | 8.7 kB | Without provenance | Details for swarmauri_tool_gmail-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarmauri_tool_gmail-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for swarmauri_tool_gmail-0.10.0-py3-none-any.whl |
Total release size: 19.1 kB
Release files / swarmauri_tool_gmail-0.10.0.tar.gz
| Download URL | swarmauri_tool_gmail-0.10.0.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3330595054aa594c7ba5875d4fa83adf776c9a9fc1f079782ab0c963e4c4404d
|
|
BLAKE2b-256 checksum How to use checksums |
ae8a196e3116e5794a36bd5e5ed5f2371e33bd0042f4380974eb4b13d04f0e9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","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}
|
Release files / swarmauri_tool_gmail-0.10.0-py3-none-any.whl
| Download URL | swarmauri_tool_gmail-0.10.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a715b04b0267da87a1eb18ccbbae9b3127190792a5e87ba9f35d474b1b0450b1
|
|
BLAKE2b-256 checksum How to use checksums |
af8f1387644c05cf72801fd924ffa10c580d835b62a5a0e4a9cb34484a7b159d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","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}
|
Security for swarmauri_tool_gmail 0.10.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.