MailerNotifier

DAG/task callback notifier that sends email via MailerHook.

class airflow.providers.mailer.notifications.mailer.MailerNotifier(*, to: list[str] | str, subject: str = 'Airflow notification', html_content: str | None = None, from_email: str | None = None, cc: list[str] | str | None = None, bcc: list[str] | str | None = None, files: list[str] | None = None, mailer_conn_id: str | None = None, mime_subtype: str = 'mixed', mime_charset: str = 'utf-8')

Basisklassen: BaseNotifier

Send an email notification via MailerHook.

Intended for use as a DAG- or task-level callback:

from airflow.providers.mailer.notifications.mailer import MailerNotifier

notifier = MailerNotifier(
    to=["ops@example.com"],
    subject="Task {{ ti.task_id }} failed",
)

with DAG(..., on_failure_callback=notifier):
    ...
Parameters:
  • to – Recipient address(es).

  • subject – Email subject. Supports Jinja templating.

  • html_content – HTML body. Defaults to a summary built from the task context.

  • from_email – Override the sender address.

  • cc – Carbon-copy address(es).

  • bcc – Blind carbon-copy address(es).

  • files – Absolute file paths to attach.

  • mailer_conn_id – Airflow connection ID (default: smtp_default).

  • mime_subtype – MIME multipart subtype (default: mixed).

  • mime_charset – Character set for the HTML body (default: utf-8).

notify(context: dict[str, Any]) → None

Send the configured email, called by Airflow with the task/DAG context.

Parameters:

context (dict[str, Any]) – The Airflow task/DAG execution context, as passed to a callback like on_failure_callback.