Sign inGet Started

Python SDK

Send email with Bottle

Use Parcel Wing from lightweight Bottle routes and WSGI apps with a server-side API key.

Install the SDK

The official SDK is published as parcelwing.

Terminal

pip install parcelwing

Route

Create a small JSON route that sends a saved template and returns a compact response.

app.py

import os
 
from bottle import HTTPResponse, request, response, route, run
from parcelwing import ParcelWing, ParcelWingError
 
parcel_wing = ParcelWing(api_key=os.environ["PARCEL_WING_API_KEY"])
 
 
@route("/send-welcome", method="POST")
def send_welcome():
body = request.json or {}
email = body.get("email")
 
response.content_type = "application/json"
 
if not email:
return HTTPResponse({"error": "Email is required"}, status=400)
 
try:
emails = parcel_wing.emails.send(
from_=os.environ.get(
"PARCEL_WING_FROM_EMAIL",
),
to=email,
template_alias="welcome_email",
template_params={
"first_name": body.get("first_name") or "friend",
},
)
return {"id": emails[0]["id"]}
except ParcelWingError as error:
return HTTPResponse(
{"code": error.code, "request_id": error.request_id},
status=error.status,
)
 
 
if __name__ == "__main__":
run(host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))

Deployment

For production WSGI hosting, run Bottle behind Gunicorn or another process manager instead of the development server.

Terminal

gunicorn app:default_app --bind 0.0.0.0:$PORT

Production notes

  • Keep PARCEL_WING_API_KEY in server-side environment variables.
  • Validate and rate limit public endpoints before sending email.
  • Use templates for repeatable lifecycle emails instead of building HTML in route handlers.