Skip to main content

SMTP integration for UserHarbor, a framework agnostic user management system for Python applications.

Project description

userharbor

GitHub License Tests Codecov PyPI - Python Version PyPI - Version Code style: black Linting: Ruff uv Pytest Zensical

Project status: UserHarbor SQLAlchemy is currently in an early stage of development. The API may change frequently. The library is not ready for production use yet.

userharbor-smtp

SMTP email sender integration for userharbor.

The package provides SMTPEmailSender, an implementation of UserHarbor's EmailSender protocol. It sends verification and password reset messages with Python's standard smtplib and renders HTML email templates with Jinja.

Installation

pip install userharbor-smtp

Usage

from userharbor_smtp import SMTPEmailSender

email_sender = SMTPEmailSender(
    host="smtp.example.com",
    port=587,
    username="smtp-user",
    password="smtp-password",
    from_email="noreply@example.com",
    from_name="UserHarbor",
)

By default, the sender uses HTML templates bundled with the package:

  • verification.html
  • password_reset.html

To use custom templates, pass a directory containing files with the same names:

email_sender = SMTPEmailSender(
    host="smtp.example.com",
    port=587,
    username="smtp-user",
    password="smtp-password",
    from_email="noreply@example.com",
    template_dir="templates/emails",
)

Each template receives:

  • username
  • email
  • token

Example templates/emails/verification.html:

<p>Hello {{ username }},</p>
<p>Use this token to verify {{ email }}:</p>
<p><strong>{{ token }}</strong></p>

Configuration

SMTPEmailSender(
    host="smtp.example.com",
    from_email="noreply@example.com",
    port=587,
    username=None,
    password=None,
    from_name=None,
    template_dir=None,
    verification_subject="Verify your email",
    password_reset_subject="Reset your password",
    use_starttls=True,
    use_ssl=False,
    timeout=10,
)

License

UserHarbor SMTP is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

userharbor_smtp-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

userharbor_smtp-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file userharbor_smtp-0.1.0.tar.gz.

File metadata

  • Download URL: userharbor_smtp-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for userharbor_smtp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b5261f6343b10f7d2c12a0df801a0d49c50a22d35e630c0f303fdaa18936b4cb
MD5 85fdcaa04ea80f98f5df514e75dec2f4
BLAKE2b-256 3609f39b683896507562bcc7c66e2dacebd8ce599c472a633b7d1c590fef3b14

See more details on using hashes here.

File details

Details for the file userharbor_smtp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: userharbor_smtp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.22 {"installer":{"name":"uv","version":"0.11.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for userharbor_smtp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4860c5ba553cecca596e708ab761eaec0b1a27c7260a203c7fa4119aa06665c
MD5 9278e932cdc1773f5175e10037cefa0e
BLAKE2b-256 a9cbaad33944f09022edbff3a38ca82ff9f98443604fa973f74ac9fcc96fc1a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page