Skip to main content
Use a secret key client for all email methods.
from mailrify import Mailrify

client = Mailrify("sk_your_secret_key")

Send with basic HTML (emails.send)

result = client.emails.send(
    to="[email protected]",
    from_={"name": "Mailrify Demo", "email": "[email protected]"},
    subject="Welcome",
    body="<h1>Hello</h1><p>Your SDK setup is working.</p>",
)

print(result.timestamp)
print(result.emails[0].email)

Send to multiple recipients

to supports strings, recipient objects, or both:
client.emails.send(
    to=["[email protected]", {"name": "Two", "email": "[email protected]"}],
    from_="[email protected]",
    subject="Product update",
    body="<p>New features are live.</p>",
)

Send with template and data

client.emails.send(
    to="[email protected]",
    from_="[email protected]",
    template="tmpl_123",
    data={"firstName": "John", "plan": "premium"},
)

Send with attachments

Attachment content should be Base64-encoded:
client.emails.send(
    to="[email protected]",
    from_="[email protected]",
    subject="Your invoice",
    body="<p>Invoice attached.</p>",
    attachments=[
        {
            "filename": "invoice.pdf",
            "content": "JVBERi0xLjQKJ...",
            "contentType": "application/pdf",
        }
    ],
)

Send with advanced options

client.emails.send(
    to={"name": "Jane Doe", "email": "[email protected]"},
    from_={"name": "Growth Team", "email": "[email protected]"},
    subject="Release notes",
    body="<p>Monthly update.</p>",
    reply="[email protected]",
    name="Monthly newsletter",
    subscribed=True,
    headers={"X-Campaign-Id": "monthly-2026-03"},
)

Verify an email address (emails.verify)

verification = client.emails.verify("[email protected]")

print(verification.valid)
print(verification.is_random_input)
print(verification.reasons)

Handle typo suggestions

verification = client.emails.verify("[email protected]")

if verification.is_typo and verification.suggested_email:
    print("Did you mean:", verification.suggested_email)

Async equivalents

AsyncMailrify exposes the same method names and parameters:
from mailrify import AsyncMailrify


async def run() -> None:
    async with AsyncMailrify("sk_your_secret_key") as client:
        await client.emails.send(
            to="[email protected]",
            from_="[email protected]",
            subject="Hello",
            body="<p>Async send</p>",
        )
        verification = await client.emails.verify("[email protected]")
        print(verification.valid)
See full endpoint details in the Send email API reference and Verify email API reference.