Official Mailrify Python SDK
Project description
Mailrify Python SDK
Official Python SDK for the Mailrify API.
Installation
pip install mailrify
Quick Start (Sync)
from mailrify import Mailrify
client = Mailrify("sk_your_api_key")
Quick Start (Async)
from mailrify import AsyncMailrify
client = AsyncMailrify("sk_your_api_key")
Emails
from mailrify import Mailrify
client = Mailrify("sk_your_api_key")
result = client.emails.send(
to="user@example.com",
from_={"name": "My App", "email": "hello@myapp.com"},
subject="Welcome!",
body="<h1>Hello {{name}}</h1>",
data={"name": "John"},
)
verification = client.emails.verify("user@example.com")
print(verification.valid, verification.is_random_input)
Events
from mailrify import Mailrify
tracker = Mailrify("pk_your_public_key")
tracker.events.track(
email="user@example.com",
event="purchase",
data={"product": "Premium", "amount": 99},
)
client = Mailrify("sk_your_api_key")
names = client.events.get_names()
Contacts
from mailrify import Mailrify
client = Mailrify("sk_your_api_key")
contacts = client.contacts.list(limit=50)
contact = client.contacts.create(email="new@example.com", data={"plan": "premium"})
client.contacts.update(contact.id, subscribed=False)
client.contacts.delete(contact.id)
count = client.contacts.count()
Segments
from mailrify import Mailrify
client = Mailrify("sk_your_api_key")
segment = client.segments.create(
name="Premium Users",
condition={
"logic": "AND",
"groups": [
{
"filters": [
{"field": "data.plan", "operator": "equals", "value": "premium"}
]
}
],
},
track_membership=True,
)
members = client.segments.list_contacts(segment.id, page=1)
Campaigns
from mailrify import Mailrify
client = Mailrify("sk_your_api_key")
campaign = client.campaigns.create(
name="Product Launch",
subject="Introducing our new feature!",
body="<h1>Big news!</h1><p>Check out our latest feature.</p>",
from_email="hello@myapp.com",
audience_type="ALL",
)
campaigns_page = client.campaigns.list(page=1, page_size=20, status="DRAFT")
client.campaigns.send(campaign.id, scheduled_for="2026-03-01T10:00:00Z")
client.campaigns.test(campaign.id, email="preview@myapp.com")
stats = client.campaigns.stats(campaign.id)
client.campaigns.cancel(campaign.id)
Async Example
import asyncio
from mailrify import AsyncMailrify
async def main() -> None:
async with AsyncMailrify("sk_your_api_key") as client:
verification = await client.emails.verify("user@example.com")
print(verification.valid)
asyncio.run(main())
Configuration
from mailrify import Mailrify
client = Mailrify(
"sk_your_api_key",
base_url="https://api.mailrify.com",
timeout=30.0,
max_retries=3,
)
Development
pip install -e .[dev]
ruff check .
mypy src/
pytest
hatch build
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
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 mailrify-1.0.1.tar.gz.
File metadata
- Download URL: mailrify-1.0.1.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21b4cb2f603b9bdbe6d4b2fc8bb9c28d0e1ad5f329e3f2b6889ae23a54eff12a
|
|
| MD5 |
8c169dd48619a7b722732de5eb0d97f2
|
|
| BLAKE2b-256 |
1e6c119a3179fac21ec8bcfea4fc811e9a2776067c3ddc715a64e6f12bd079c8
|
Provenance
The following attestation bundles were made for mailrify-1.0.1.tar.gz:
Publisher:
publish.yml on Mailrify/mailrify-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mailrify-1.0.1.tar.gz -
Subject digest:
21b4cb2f603b9bdbe6d4b2fc8bb9c28d0e1ad5f329e3f2b6889ae23a54eff12a - Sigstore transparency entry: 954829815
- Sigstore integration time:
-
Permalink:
Mailrify/mailrify-python@b0e4b1eabbb8618ab11d452fe00bdc7b8200cd1e -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Mailrify
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b0e4b1eabbb8618ab11d452fe00bdc7b8200cd1e -
Trigger Event:
release
-
Statement type:
File details
Details for the file mailrify-1.0.1-py3-none-any.whl.
File metadata
- Download URL: mailrify-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9689bfe95700224494f9cbcae425bb885e7d40af12837b83a2e21c53165efc07
|
|
| MD5 |
2ba9bf72bde094b3baa92030e869ac27
|
|
| BLAKE2b-256 |
ce6d7341ab82f20bdda4d9149c3503f5af2634972d08bfa90cbf8bb397824a51
|
Provenance
The following attestation bundles were made for mailrify-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on Mailrify/mailrify-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mailrify-1.0.1-py3-none-any.whl -
Subject digest:
9689bfe95700224494f9cbcae425bb885e7d40af12837b83a2e21c53165efc07 - Sigstore transparency entry: 954829816
- Sigstore integration time:
-
Permalink:
Mailrify/mailrify-python@b0e4b1eabbb8618ab11d452fe00bdc7b8200cd1e -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Mailrify
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b0e4b1eabbb8618ab11d452fe00bdc7b8200cd1e -
Trigger Event:
release
-
Statement type: