Skip to main content

SendFn Python SDK

Self-hosted communications platform SDK for email, push notifications, and SMS.

Installation

pip install sendfn

For email support (AWS SES):

pip install sendfn[email]

For push notification support:

pip install sendfn[push]

For all features:

pip install sendfn[all]

Quick Start

Email Sending

from sendfn import create_sendfn, SendfnConfig
from sendfn.models import EmailConfig, AwsSesConfig, SendEmailParams
from sendfn.database import MemoryAdapter

# Create configuration
config = SendfnConfig(
    database=MemoryAdapter(),
    email=EmailConfig(
        from_email="noreply@example.com",
        from_name="My App",
        aws_ses=AwsSesConfig(
            access_key_id="YOUR_ACCESS_KEY",
            secret_access_key="YOUR_SECRET_KEY",
            region="us-east-1",
        ),
    ),
)

# Create client
sendfn = create_sendfn(config)

# Send an email
transaction = await sendfn.send_email(
    SendEmailParams(
        user_id="user-123",
        to="user@example.com",
        subject="Welcome!",
        html="<h1>Welcome to our app!</h1>",
        text="Welcome to our app!",
    )
)

print(f"Email sent! Transaction ID: {transaction.id}")

Using Templates

from sendfn.models import EmailTemplate

# Register a custom template
template = EmailTemplate(
    id="welcome",
    name="Welcome Email",
    subject="Welcome to {{appName}}!",
    html="<h1>Hi {{userName}}!</h1><p>Welcome to {{appName}}.</p>",
    variables=["userName", "appName"],
)

await sendfn.register_template(template)

# Send email using template
transaction = await sendfn.send_email(
    SendEmailParams(
        user_id="user-123",
        to="user@example.com",
        template_id="welcome",
        template_data={
            "userName": "John",
            "appName": "My App",
        },
    )
)

Suppression List

# Check if email is suppressed
result = await sendfn.check_suppression_list("user@example.com")
if result["suppressed"]:
    print(f"Email is suppressed: {result['entry'].reason}")

# Add to suppression list
await sendfn.add_to_suppression_list(
    email="spam@example.com",
    reason="manual",
    source="admin-action",
)

# Remove from suppression list
await sendfn.remove_from_suppression_list("user@example.com")

Event Tracking

# Get events for an email transaction
events = await sendfn.get_email_events(transaction_id="...")

for event in events:
    print(f"{event.event_type} at {event.event_timestamp}")

Features

  • ✅ Email Sending - AWS SES support with attachments
  • ✅ Template Engine - Variable interpolation, conditionals, loops
  • ✅ Suppression Lists - Automatic bounce and complaint handling
  • ✅ Event Tracking - Track delivery, bounces, opens, clicks
  • ✅ Database Agnostic - Works with any database via adapters
  • ⏳ Push Notifications - FCM and APNS support (coming soon)
  • ⏳ SMS - SMS sending support (coming soon)

Configuration

Email Configuration

EmailConfig(
    from_email="noreply@example.com",  # Required
    from_name="My App",  # Optional
    reply_to="support@example.com",  # Optional
    aws_ses=AwsSesConfig(
        access_key_id="...",
        secret_access_key="...",
        region="us-east-1",
        configuration_set_name="my-config-set",  # Optional
    ),
)

Options

SendfnOptions(
    suppression_enabled=True,  # Enable suppression list checking
    retry_attempts=3,  # Number of retry attempts
    retry_delay=1000,  # Delay between retries (ms)
    event_tracking=True,  # Enable event tracking
)

Database Adapters

Memory Adapter (for testing)

from sendfn.database import MemoryAdapter

adapter = MemoryAdapter()

With Superfunctions DB

from superfunctions.db import create_adapter

adapter = create_adapter({
    "type": "postgres",
    "connection_string": "postgresql://...",
})

Development

# Install dependencies
make install

# Run tests
make test

# Lint code
make lint

# Format code
make format

License

MIT License - see LICENSE file for details.

Metadata

Release files for sendfn 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sendfn 0.0.1
File Size Uploaded Provenance Actions
sendfn-0.0.1.tar.gz 32.9 kB Without provenance Details for sendfn-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sendfn 0.0.1
File Interpreter ABI Platform Actions
sendfn-0.0.1-py3-none-any.whl Python 3 none any Details for sendfn-0.0.1-py3-none-any.whl

Total release size: 76.0 kB

Release files / sendfn-0.0.1.tar.gz

Download URL sendfn-0.0.1.tar.gz
Size 32.9 kB
Tags Source
SHA-256 checksum
How to use checksums
651a9e5347fe7ec1ef2b57a872ea956f1c7609419cfb1c120ef3a6ed65c17f6a
BLAKE2b-256 checksum
How to use checksums
5c2d3c24858bee5f35eb9127db5747b0ee6f8a23c7921e188f1f653f142903ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / sendfn-0.0.1-py3-none-any.whl

Download URL sendfn-0.0.1-py3-none-any.whl
Size 43.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e39418ce094bd161e9ad2d4600826d1857806da62ccf347162afcf765b198ed
BLAKE2b-256 checksum
How to use checksums
9bc5db771fbb57b2e2d1ee9bbefbeaf5571552d6a6f4e95547131117573ba9ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for sendfn 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page