notification_utils
frequenz.lib.notebooks.notification_utils ¤
Utility functions to support testing, validating, and previewing email notifications.
These are intended to be used in notebooks, Streamlit apps, or other tools that help users configure and debug their notification settings interactively.
Classes¤
Functions¤
frequenz.lib.notebooks.notification_utils.format_email_preview ¤
Wrap a pre-built HTML email body with a minimal structure for previewing.
PARAMETER | DESCRIPTION |
---|---|
subject
|
The subject line of the email.
TYPE:
|
body_html
|
The formatted HTML body.
TYPE:
|
attachments
|
Optional list of attachment filenames to display (names only). |
RETURNS | DESCRIPTION |
---|---|
str
|
Full HTML string. |
Source code in frequenz/lib/notebooks/notification_utils.py
frequenz.lib.notebooks.notification_utils.send_test_email ¤
send_test_email(config: EmailConfig) -> tuple[bool, str]
Send a test email using the given EmailConfig.
The email message is generated automatically based on the provided configuration and replaces the provided one.
PARAMETER | DESCRIPTION |
---|---|
config
|
An EmailConfig instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple[bool, str]
|
Tuple of (success_flag, message). |
Source code in frequenz/lib/notebooks/notification_utils.py
frequenz.lib.notebooks.notification_utils.validate_email_config ¤
validate_email_config(
config: EmailConfig,
check_connectivity: bool = False,
check_attachments: bool = False,
) -> list[str]
Validate the EmailConfig for completeness and optional connectivity.
PARAMETER | DESCRIPTION |
---|---|
config
|
An EmailConfig instance.
TYPE:
|
check_connectivity
|
If True, tests SMTP login credentials.
TYPE:
|
check_attachments
|
If True, verifies that each attachment exists.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[str]
|
A list of error messages. If empty, the config is considered valid. |