Skip to main content

example community package

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_gmail

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

  • GmailSendTool sends HTML emails to one or more recipients.
  • GmailReadTool fetches messages matching a Gmail search query and formats key headers.
  • Both tools authenticate with googleapiclient using 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.send and/or https://www.googleapis.com/auth/gmail.readonly scopes.
  • Install google-api-python-client and google-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

swarmauri_tool_gmail-0.10.1.dev3.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

swarmauri_tool_gmail-0.10.1.dev3-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_tool_gmail-0.10.1.dev3.tar.gz.

File metadata

  • Download URL: swarmauri_tool_gmail-0.10.1.dev3.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","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

Hashes for swarmauri_tool_gmail-0.10.1.dev3.tar.gz
Algorithm Hash digest
SHA256 7e8df63d0c3b71f4e3abe9b7c2f5b5b562f46cef779ecb54df004683c7aca8ed
MD5 6240b1527a42dc3cb96095fbf6e42c63
BLAKE2b-256 8e1008d61a0f9e9502babadebd8e9e054f20424c2d8830c5c6f7c84403f85799

See more details on using hashes here.

File details

Details for the file swarmauri_tool_gmail-0.10.1.dev3-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_gmail-0.10.1.dev3-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","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

Hashes for swarmauri_tool_gmail-0.10.1.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 aeb9974d27f01df2badd96df1cc652d2c03a53b6d565ef02c76504d2ba538252
MD5 a7b6e6f06799e9589590a594f2fa5946
BLAKE2b-256 47887c736d57f49066353148276988b0edcc81e4ed516c73dc9e9d9118556a0b

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