Skip to main content

Sending Alerts

Sending emails from execute function

Templated email notifications can be sent from the execute function by using the GanymedeEmailAlert object in ganymede_sdk.util.

GanymedeEmailAlert takes 2 parameters

  • param ganymede_context: GanymedeContext - GanymedeContext object associated with the flow run
  • param html_template: str - HTML Jinja template for the email, rendered using the ganymede_context object. A Ganymede-specific template is used by default.
from ganymede_sdk import Ganymede
from ganymede_sdk.util.email import GanymedeEmailAlert

g = Ganymede()

email_alert = GanymedeEmailAlert(g.ganymede_context)
email_alert.send_email(
"user@email.com", "My subject", "My message to send",
cc="user@ganymede.bio",
bcc="user@email.com"
)

method send_email

send_email sends an email notification to the specified recipient(s). The method returns the HTML object of the email sent.

  • param to : str | Iterable[str] - The recipient(s) of the email. This can be a single email address (str) or a list of email addresses (Iterable).
  • param subject : str - The subject of the email.
  • param message : str - The plain text message content.
  • param cc : str | Iterable[str] | None - The recipient(s) to be copied on the email (CC), by default None. This can be a single email address or a list of email addresses.
  • param bcc : str | Iterable[str] | None - The recipient(s) to be blindly copied on the email (BCC), by default None. This can be a single email address or a list of email addresses.
  • param custom_headers : dict[str, Any] | None - A dictionary of custom email headers, by default None.