Skip to content

Blog / All posts

Send email with Python

Install the bavimail package, set your API key and send an email with client.emails.send(). Then check delivery and read replies. Tested against the live Bavimail API on October 14, 2026.

Originally published

Install bavimail, set your API key, and call client.emails.send() with an alias id, a recipient, a subject and an HTML body. Every snippet below ran against the live Bavimail API on October 14, 2026, with bavimail 0.1.17 on Python 3.11.

Bavimail email is Live, with a free plan.

What you need

  • A Bavimail account. Start free, no credit card.
  • A verified domain with at least one address on it. See domains.
  • An API key from the dashboard.
  • Python 3.9 or later.

1. Install the SDK and set your key

pip install bavimail
export BAVIMAIL_API_KEY=your_api_key

2. Find the address to send from

Each address on your domain is an alias with an id. emails.send() takes the id.

import os
from bavimail import Bavimail

client = Bavimail(api_key=os.environ["BAVIMAIL_API_KEY"])

for alias in client.aliases.list():
    print(alias.id, alias.full_email)

Set the id of the address you want as BAVIMAIL_ALIAS_ID.

3. Send an email

import os
from bavimail import Bavimail

client = Bavimail(api_key=os.environ["BAVIMAIL_API_KEY"])

email = client.emails.send(
    alias_id=os.environ["BAVIMAIL_ALIAS_ID"],
    to_email="[email protected]",
    subject="Hello from Python",
    body="<p>Sent with the Bavimail Python SDK.</p>",
)
print(email.id, email.status)

It prints the email id and queued.

4. Check delivery

A few seconds later:

print(client.emails.get(email.id).status)

In our test it printed delivered 10 seconds after the send.

5. Read replies

import os
from bavimail import Bavimail

client = Bavimail(api_key=os.environ["BAVIMAIL_API_KEY"])

for message in client.inbound_emails.list(alias_id=os.environ["BAVIMAIL_ALIAS_ID"], limit=10):
    print(message.created_at, message.from_email, message.subject)

To get replies as they arrive instead of polling, use webhooks.

FAQ

How do I send an email with Python?

Install bavimail with pip, set BAVIMAIL_API_KEY, and call client.emails.send() with an alias id, a recipient, a subject and an HTML body.

Which Python versions does the SDK support?

Python 3.9 or later.

How do I know the email was delivered?

Call client.emails.get(email_id) and read status. A new email starts as queued and moves to delivered.

How much does it cost?

The free plan has 6,000 emails a month and 200 a day, with no credit card. The Developer plan is US$5 a month for 50,000 emails. See pricing.

← All posts