Skip to main content

notifyvia-email

The frontend Python library for notifyvia.email.

Installation

pip install notifyvia-email

or with uv:

uv add notifyvia-email

Requires Python 3.13+.

Quick start

from notifyvia_email.v3 import NotifyViaEmail, SendResult

client = NotifyViaEmail(api_key="your-api-key")

resp = client.send(
    to="you@example.com",
    subject="A message from your website",
    text="Do you have any strawberry cheesecake?",
)

if resp.ok:
    print("Email queued for delivery")
else:
    print(resp.result, resp.errors)

API versions

Each API version has its own client with the same interface:

from notifyvia_email.v1 import NotifyViaEmail  # POST /api/v1/send
from notifyvia_email.v2 import NotifyViaEmail  # POST /api/v2/send
from notifyvia_email.v3 import NotifyViaEmail  # POST /api/v3/send

v2 adds the reply_to parameter. v3 adds Cap captcha verification (see Captcha (v3)). Everything else is shared.

Sending HTML

Provide html, text, or both. At least one is required, otherwise send() raises ValueError.

resp = client.send(
    to="you@example.com",
    subject="Welcome!",
    html="<h1>Welcome</h1><p>Thanks for signing up.</p>",
    text="Welcome! Thanks for signing up.",
    reply_to="support@example.com",  # v2 and v3 only
)

Spam checking and rate limiting

A typical contact form setup. The rate limiter needs the sender's IPv4 address.

resp = client.send(
    to="owner@example.com",
    subject="New contact form submission",
    text=form_message,
    enable_spam_checker=True,
    enable_rate_limiter=True,
    limit=3,             # max requests...
    within_seconds=300,  # ...per 5 minutes, per IP
    ipv4_address=request.remote_addr,
)

Captcha (v3)

The v3 client can have notifyvia.email verify a Cap captcha token before sending. Cap is self-hosted, so you need your own Cap instance with your website added to it.

Set the Cap secret key and siteverify endpoint once when creating the client:

from notifyvia_email.v3 import NotifyViaEmail, SendResult

client = NotifyViaEmail(
    api_key="your-api-key",
    cap_secret_key=CAP_SECRET_KEY,
    cap_api_endpoint=CAP_API_ENDPOINT,  # https://cap.example.com/<site-key>/siteverify
)

If you don't pass them, the client reads the CAP_SECRET_KEY and CAP_API_ENDPOINT environment variables:

export CAP_SECRET_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
export CAP_API_ENDPOINT="https://cap.example.com/0000000/siteverify"
client = NotifyViaEmail(api_key="your-api-key")  # captcha enabled from the environment

/siteverify is added to the endpoint if you leave it off, so https://cap.example.com/0000000 also works.

Then pass the token from your frontend form (the cap-token field the Cap widget adds) to each send() call:

resp = client.send(
    to="owner@example.com",
    subject="New contact form submission",
    text=form_message,
    cap_token=request.form["cap-token"],
)

if resp.result is SendResult.CAPTCHA_VERIFICATION_FAILED:
    print("Captcha failed:", resp.errors)

Notes:

  • The captcha is only enabled when both the secret key and the endpoint are set. Otherwise v3 sends without a captcha check, and any cap_token is ignored.
  • notifyvia.email calls your Cap instance, so in Cap either turn off Restrict allowed origins (CORS) or add notifyvia.email to the allowed list. Otherwise every send fails with CAPTCHA_VERIFICATION_FAILED.
  • CAPTCHA_VERIFICATION_FAILED means the token, the endpoint, or the secret key is invalid. resp.errors says which.
  • Cap tokens are single-use, so get a new one for each submission.

Choosing a service

resp = client.send(
    to="you@example.com",
    subject="Hello",
    text="Sent via Postmark",
    service="postmark",  # "zepto" (default) or "postmark"
)

Handling the response

send() returns a SendResponse with:

  • result: a SendResult enum member
  • errors: the API's errors field (or None), e.g. per-field validation messages
  • ok: True when the email was accepted for delivery
from notifyvia_email.v3 import SendResult

resp = client.send(to="not-an-email", subject="Hi", text="Hello")

match resp.result:
    case SendResult.EMAIL_PROVISIONING:
        print("Sent")
    case SendResult.INVALID:
        print("Validation failed:", resp.errors)
        # {'to': ['Not a valid email address.']}
    case SendResult.RATE_LIMIT_EXCEEDED:
        print("Too many requests, try again later")
    case SendResult.SPAM_DETECTED:
        print("Message rejected as spam")
    case SendResult.CAPTCHA_VERIFICATION_FAILED:
        print("Captcha failed:", resp.errors)
    case SendResult.CONNECTION_ERROR:
        print("Could not reach notifyvia.email:", resp.errors)
    case _:
        print("Failed:", resp.result.name, resp.errors)
SendResult HTTP Meaning
EMAIL_PROVISIONING 200 Accepted and queued for delivery
AUTHORIZATION_REQUIRED 401 Missing or invalid API key
RATE_LIMIT_EXCEEDED 429 Too many requests from this IP in the window
INVALID 460 Request validation failed (see errors)
INVALID_ACCOUNT 461 API key accepted but no matching account
INVALID_SERVICE 462 service is not a supported provider
INSUFFICIENT_CREDITS 463 Not enough credits to send
IPV4_ADDRESS_NOT_PROVIDED 464 Rate limiter enabled without ipv4_address
SPAM_DETECTED 465 Body matched the spam dictionary
SENDER_IPV4_BLOCKED 466 Sender IP is on the global block list
CAPTCHA_VERIFICATION_FAILED 467 Captcha token, endpoint, or secret key invalid (v3)
UNKNOWN_ERROR - Unexpected status code from the API
CONNECTION_ERROR - Network failure or timeout; errors has details

Configuration

client = NotifyViaEmail(api_key="your-api-key", timeout=5.0)  # seconds, default 10

See the notifyvia.email docs for full API details.

Metadata

Release files for notifyvia-email 1.0.0

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

Source distribution (sdist)

Source distribution for notifyvia-email 1.0.0
File Size Uploaded Provenance Actions
notifyvia_email-1.0.0.tar.gz 5.5 kB Without provenance Details for notifyvia_email-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for notifyvia-email 1.0.0
File Interpreter ABI Platform Actions
notifyvia_email-1.0.0-py3-none-any.whl Python 3 none any Details for notifyvia_email-1.0.0-py3-none-any.whl

Total release size: 13.3 kB

Release files / notifyvia_email-1.0.0.tar.gz

Download URL notifyvia_email-1.0.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a752e12fedc745e818c1b4b87f6cae8b690384b0c1b8fae006b63e4fd6c7195c
BLAKE2b-256 checksum
How to use checksums
17fa7e02671969a20f83d5fbe357da50f0293499322e17243a09e991ce05d897
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / notifyvia_email-1.0.0-py3-none-any.whl

Download URL notifyvia_email-1.0.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
535c92d020a933394ff206cf3a1cadfbc5a2724f7ae0fb60530825a5298797fc
BLAKE2b-256 checksum
How to use checksums
7f8d6f6059e5162963fdbe7ae79dd0c3162d720c4314acb6c5a8d98005e4b434
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for notifyvia-email 1.0.0

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

1.0.0 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