Send email
with Python

Send with requests, httpx or the standard library’s smtplib. Works in Flask, FastAPI, scripts and background workers.

POST/v1/send
200 OK
To
ana@acme.com
From
Acme <hello@acme.com>
Subject
Reset your password

Reset your password

To ana@acme.com

  1. Sent09:41:02
  2. Delivered09:41:03
  3. Opened09:42:18

Before you send

  1. Create a project

    Sign up for free and copy your secret key from the project settings.

  2. Verify your domain

    Add the DNS records Plunk shows you. It checks them and tells you when you can send.

  3. Send

    Use the API or your framework’s mailer, below. Every email shows up in the dashboard.

Send with the API

One POST request. Any HTTP client works the same way; this uses requests.

send.py
import os
import requests

response = requests.post(
    "https://send-api.akmarketingseo.com/v1/send",
    headers={"Authorization": f"Bearer {os.environ['PLUNK_SECRET_KEY']}"},
    json={
        "to": "ana@acme.com",
        "subject": "Welcome to Acme",
        "body": "<p>Thanks for signing up.</p>",
    },
    timeout=10,
)
response.raise_for_status()

Send with Python over SMTP

No dependencies at all: the standard library can send over SMTP.

send_smtp.py
import os
import smtplib
from email.message import EmailMessage

message = EmailMessage()
message["From"] = "Acme <hello@acme.com>"
message["To"] = "ana@acme.com"
message["Subject"] = "Welcome to Acme"
message.set_content("Thanks for signing up.")
message.add_alternative("<p>Thanks for signing up.</p>", subtype="html")

with smtplib.SMTP("smtp.useplunk.com", 587) as smtp:
    smtp.starttls()
    smtp.login("plunk", os.environ["PLUNK_SECRET_KEY"])
    smtp.send_message(message)

Frequently asked questions

Send your first email from Python.

Start on the free plan with 1,000 emails a month, no credit card needed. When you need more, every email is $0.001, with unlimited contacts and every feature included.