EmailOperator

Operator that sends an email as a DAG task, via MailerHook.

class airflow.providers.mailer.operators.email.EmailOperator(*, to: list[str] | str, subject: str, html_content: str, 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 = 'smtp_default', mime_subtype: str = 'mixed', mime_charset: str = 'utf-8', **kwargs)

Bases: BaseOperator

Send an email using MailerHook.

Parameters:
  • to – Recipient address(es).

  • subject – Email subject. Supports Jinja templating.

  • html_content – HTML body. Supports Jinja templating and .html file references.

  • from_email – Override the sender address (defaults to connection login / extras.from_email).

  • cc – Carbon-copy address(es).

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

  • files – List of absolute file paths to attach.

  • mailer_conn_id – Airflow connection ID (default: smtp_default). Point this at Airflow’s standard SMTP connection for plain SMTP, or at a mailer_graph / mailer_smtp_oauth connection for Microsoft Graph or SMTP OAuth2 delivery.

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

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

execute(context) → None

Send the configured email; called by Airflow when the task runs.

Parameters:

context – The Airflow task execution context (unused; email fields are already rendered by templating before execute runs).