email

Module for the Email messenger.

This module defines the Email messenger class, which is used to send notifications via email.

Typical usage example:

from herald.decorators import Herald
from herald.messengers import EmailMessenger

herald = Herald(".env")
email = EmailMessenger()

@herald(email)
def my_function():
   pass

Classes

EmailMessenger

A class for sending notifications via email.

class EmailMessenger(recipient)[source]

Bases: Messenger

A class for sending notifications via email.

Parameters:
  • recipient (str) – String containing the email address of the recipient.

  • smtp_server – String containing the SMTP server address.

  • smtp_port – Integer containing the SMTP server port.

  • smtp_starttls – Boolean indicating whether to use STARTTLS.

  • smtp_user – String containing the SMTP username.

  • smtp_password – String containing the SMTP password.

__init__(recipient)[source]

Initializes the EmailMessenger with the given recipient.

Parameters:

recipient (str) – String containing the email address of the recipient.

set_secrets(secrets)[source]

Sets the secrets for the EmailMessenger.

Secrets required are the SMTP details for the server that will be sending the email.

Parameters:

secrets (Secrets) – Secrets for the EmailMessenger.

Return type:

None

notify(info)[source]

Creates and sends an email with the given TaskInfo.

Parameters:

info (TaskInfo) – TaskInfo object containing the information to be sent. Contents should be used to create the email.

Raises:

SMTPException – An error occurred while sending the email.

Return type:

None