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 — Resend
import resend
resend.api_key = "re_xxxxx"
resend.Emails.send({
"from": "hello@yourdomain.com",
"to": "user@example.com",
"subject": "Welcome!",
"html": "<h1>Welcome</h1>",
})
# After — Veil Mail
from veilmail import VeilMail
client = 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
pip install veilmailOr install from source:
pip install git+https://github.com/Resonia-Health/veilmail-python.gitRequires Python 3.9+.
from veilmail import VeilMail
client = 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 reservesfromas a keyword, so the SDK usesfrom_emailas the parameter name. This is the only significant field rename versus the Resend / SendGrid Python SDKs.
- 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
typefield - Typed with mypy — full type hints across the public surface
- Built on
httpx— modern HTTP client with connection pooling
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
)from veilmail import (
VeilMail,
VeilMailError,
AuthenticationError,
ValidationError,
PiiDetectedError,
RateLimitError,
)
try:
client.emails.send(...)
except PiiDetectedError as e:
print(f"PII detected: {e.pii_types}")
except RateLimitError as e:
print(f"Rate limited, retry after: {e.retry_after}")
except AuthenticationError:
print("Invalid API key")
except VeilMailError as e:
print(f"API error: {e.code} - {e}")client = VeilMail(
api_key="veil_live_xxxxx",
base_url="https://api.veilmail.xyz", # Optional
timeout=30.0, # Optional, in seconds
)- Full documentation
- Python SDK reference
- Email API reference
- Authentication
- Webhooks
- MCP server for Claude/Cursor
- Framework guides: FastAPI · Django
MIT — see LICENSE for details.