SMTP email sender integration for
userharbor.
The package provides SMTPEmailSender, an implementation of UserHarbor's
EmailSender protocol. It sends verification, password reset, and account
security notification 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.htmlpassword_reset.htmlemail_verified.htmlpassword_changed.htmlaccount_deleted.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:
usernameemailtokenfor verification and password reset messages
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",
email_verified_subject="Email verified",
password_changed_subject="Password changed",
account_deleted_subject="Account deleted",
use_starttls=True,
use_ssl=False,
ssl_context=None,
allow_insecure=False,
timeout=10,
)
TLS certificate and hostname verification use Python's secure default SSL
context. Pass ssl_context only when the application needs a custom trusted
certificate authority or TLS policy. At least one of use_starttls and
use_ssl must be enabled by default. Set allow_insecure=True only for a
trusted local SMTP relay where plaintext transport is an explicit decision.
License
UserHarbor SMTP is released under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file userharbor_smtp-0.3.0.tar.gz.
File metadata
- Download URL: userharbor_smtp-0.3.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b0c43d321c0d11bf7c7fe778cdad606cef87c9889c2560b0640a242a2203a4f
|
|
| MD5 |
6911ca99daa0c6431ee241834734babc
|
|
| BLAKE2b-256 |
d18a9a5ce43fe049511c2198c22eba99a5d21bfcf7c72f4105f4ae305af30874
|
File details
Details for the file userharbor_smtp-0.3.0-py3-none-any.whl.
File metadata
- Download URL: userharbor_smtp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
944335600b49235fbfc146d79f9608b7f7ff6307d3a02ea25b9c0233803e1855
|
|
| MD5 |
e58b732ac73e86069a4d778cdb0868ac
|
|
| BLAKE2b-256 |
46b0635dcba0ea0b558f5c9fab0eefd0223a2d19a5231a99d1e79b509c43e30d
|