Skip to main content

Official Python SDK for Mailrify

Project description

Mailrify Python SDK

CI Release

Official Python SDK for the Mailrify transactional and marketing email API. The SDK provides a thin, type-safe wrapper over the Mailrify REST endpoints generated from the public OpenAPI contract.

Installation

Install from PyPI (Python 3.9+):

pip install mailrify

Tip: Ensure VS Code (or your editor) is using the same interpreter or virtual environment where you installed mailrify, otherwise Pylance may report missing imports.

Quickstart (Sync)

import mailrify
from mailrify.models import SendEmailRequest

mailrify.api_key = "YOUR_API_KEY"

# Method 1: Provide a plain dict; the SDK will shape it into the expected request behind the scenes.
params: mailrify.Emails.SendParams = {
    "from": "Your app <no-reply@yourdomain.com>",
    "to": ["client@example.com"],
    "subject": "Welcome to Mailrify 🚀",
    "html": "<p>It works! 👋</p>",
    "text": "It works!"
}

email: mailrify.Emails.SendResponse = mailrify.Emails.send(params)
print(email)

# Method 2: Build the helper request object explicitly for better editor assistance.
emailData = SendEmailRequest(
    from_= "Your app <no-reply@yourdomain.com>",
    to=["client@example.com"],
    subject="Welcome to Mailrify 🚀",
    html="<p>It works! 👋</p>",
    text="It works!"
)

email = mailrify.Emails.send(emailData)
print(email)

Quickstart (Async)

import asyncio
import mailrify


async def main() -> None:
    async with mailrify.AsyncClient(api_key="YOUR_API_KEY") as client:
        email = await client.emails.send(
            {
                "from": "Your app <no-reply@yourdomain.com>",
                "to": ["client@example.com"],
                "subject": "Welcome to Mailrify 🚀",
                "html": "<p>It works! 👋</p>",
                "text": "It works!"
            }
        )
        print(email.emailId)


asyncio.run(main())

Project Layout

  • src/mailrify/: core SDK implementation
  • scripts/sync_openapi.py: fetches the OpenAPI spec and regenerates models
  • tests/: unit and integration tests (to be added)

Development Setup

python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]

Run quality gates:

ruff check src tests
black --check src tests
mypy src
pytest

Integration Tests

Integration tests exercise the live Mailrify API and are skipped unless you opt in. Export the required credentials first:

export MAILRIFY_API_KEY="your_live_api_key"
export MAILRIFY_INTEGRATION_FROM="verified-sender@yourdomain.com"
export MAILRIFY_INTEGRATION_TO="recipient@example.com"
# optional override
export MAILRIFY_BASE_URL="https://app.mailrify.com/api"

Then run:

pytest -m integration

The suite currently includes a smoke test for listing emails and sending a single message; ensure the addresses you provide are valid in your Mailrify account.

Contributing

Contributions are welcome! Please open an issue or pull request after reading CONTRIBUTING.md.

License

Distributed under the terms of the MIT License.

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

mailrify-0.0.4.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

mailrify-0.0.4-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mailrify-0.0.4.tar.gz
Algorithm Hash digest
SHA256 097e3885bc9f6c0b4067996e2bfb6b588f04c9600d1d190eabc609b813245834
MD5 6d8e13973a2476b8413b0e7f97ddb919
BLAKE2b-256 606d36afd2f6f646a9f7dd3b5234c7c13ddaae31b96498bec87376b71ee96123

See more details on using hashes here.

Provenance

The following attestation bundles were made for mailrify-0.0.4.tar.gz:

Publisher: release.yml on Mailrify/mailrify-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

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

File hashes

Hashes for mailrify-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 20d0438c4b577d89715f5a2ee27880a6e5f5b1d80530806edbf5b6201521bfd1
MD5 df77ff7d069aa6c6a7d95303c23e9495
BLAKE2b-256 5d5df64650c2b9e0dea76395b559042a81f44ae22c52c37e36fa1605b1c1522c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mailrify-0.0.4-py3-none-any.whl:

Publisher: release.yml on Mailrify/mailrify-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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