Send an email with Thinwrap (Python)
Send transactional email via the Thinwrap Email facade in Python — one call shape for SendGrid, AWS SES, Resend and 7 more.
1. Install
pip install thinwrap-notifications2. Send the call
import os
from thinwrap.notifications import Email, EmailSendInput, SendgridConfig, ConnectorError
e = Email(SendgridConfig(
api_key=os.environ["SENDGRID_API_KEY"],
from_="noreply@example.com",
))
try:
res = e.send(EmailSendInput(
to="user@example.com",
subject="Hello from Thinwrap",
text="Hello world",
))
# res.status is sent | queued | rejected | suppressed | unknown
# res.provider_message_id is the upstream message id, or ""
print(res.status.value, res.provider_message_id)
except ConnectorError as err:
print(f"{err.provider_code.value}: {err.provider_message}")
Same code works for all supported providers — just change the provider ID.