Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Veil Mail Python SDK

PyPI versionPython VersionLicense: MIT

The official Python SDK for Veil Mail — secure transactional and marketing email with automatic PII protection, CASL compliance, and a developer-first API.

Veil Mail is a drop-in alternative to Resend, SendGrid, Mailgun, and Postmark. If you're already using one of these, migration is typically a package swap and a few renamed arguments.

# Before — Resendimportresendresend.api_key="re_xxxxx"resend.Emails.send({
"from": "hello@yourdomain.com",
"to": "user@example.com",
"subject": "Welcome!",
"html": "<h1>Welcome</h1>",
})
# After — Veil MailfromveilmailimportVeilMailclient=VeilMail("veil_live_xxxxx")
client.emails.send(
from_email="hello@yourdomain.com",
to="user@example.com",
subject="Welcome!",
html="<h1>Welcome</h1>",
)

Migration guides:from Resend · from SendGrid · from Mailgun · from Postmark

Installation

pip install veilmail

Or install from source:

pip install git+https://github.com/Resonia-Health/veilmail-python.git

Requires Python 3.9+.

Quick Start

fromveilmailimportVeilMailclient=VeilMail("veil_live_xxxxx")
email=client.emails.send(
from_email="hello@yourdomain.com",
to="user@example.com",
subject="Hello!",
html="<h1>Welcome!</h1>",
)
print(f"Sent: {email['id']}")

Note on from_email: Python reserves from as a keyword, so the SDK uses from_email as the parameter name. This is the only significant field rename versus the Resend / SendGrid Python SDKs.

Features

  • Automatic PII protection — every email is scanned for SSNs, credit cards, medical records, and other sensitive data via Google Cloud DLP before delivery
  • CASL & GDPR compliance — built-in consent tracking, subscription topics, and compliant unsubscribe handling
  • Drop-in alternative to Resend, SendGrid, Mailgun, and Postmark Python SDKs
  • Transactional + marketing — one API for both, classified via the type field
  • Typed with mypy — full type hints across the public surface
  • Built on httpx — modern HTTP client with connection pooling

Sending Marketing Emails

Set type="marketing" to automatically add unsubscribe headers, footer, and suppression checks:

client.emails.send(
from_email="news@yourdomain.com",
to="subscriber@example.com",
subject="Monthly Newsletter",
html="<h1>Updates</h1>",
type="marketing", # Adds List-Unsubscribe headers, footer, physical address
)

Error Handling

fromveilmailimport (
VeilMail,
VeilMailError,
AuthenticationError,
ValidationError,
PiiDetectedError,
RateLimitError,
)
try:
client.emails.send(...)
exceptPiiDetectedErrorase:
print(f"PII detected: {e.pii_types}")
exceptRateLimitErrorase:
print(f"Rate limited, retry after: {e.retry_after}")
exceptAuthenticationError:
print("Invalid API key")
exceptVeilMailErrorase:
print(f"API error: {e.code} - {e}")

Configuration

client=VeilMail(
api_key="veil_live_xxxxx",
base_url="https://api.veilmail.xyz", # Optionaltimeout=30.0, # Optional, in seconds
)

Resources

License

MIT — see LICENSE for details.

About

Official Python SDK for Veil Mail — secure transactional and marketing email with automatic PII protection. A drop-in alternative to Resend, SendGrid, Mailgun, and Postmark.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages