Skip to content

Conversation

@ferruzzi
Copy link
Contributor

@ferruzzi ferruzzi commented Sep 25, 2025

What it says in the title.

Manually tested using the following Dags (you will need an AWS account and use the SES console to verify the required email addresses)

from datetime import datetime, timedelta

from airflow.providers.amazon.aws.hooks.ses import SesHook
from airflow.providers.amazon.aws.notifications.ses import SesNotifier
from airflow.sdk import task, DAG
from airflow.sdk.definitions.deadline import DeadlineAlert, DeadlineReference, AsyncCallback

PAST_DATE = datetime(1980, 8, 10, 2)
MSG_PREFIX = "SES Testing Rnd 3:"

DEFAULTS = {
    "mail_from": << REDACTED >>,
    "to": << REDACTED >>,
    "html_content": "message body goes here"
}


def _ses_callback(context):
    SesHook().send_email(**DEFAULTS, subject=f"{MSG_PREFIX} Hook as Callback -- {context['dag_run'].dag_id}")


@task
def send_ses_email(subject):
    SesHook().send_email(**DEFAULTS, subject=subject)


@task.bash(task_id='sleep_task')
def sleep_n_secs(seconds):
    return f'sleep {seconds}'


with DAG(
    "ses_hook_via_taskflow",
    tags=["ses"]
):
    send_ses_email(subject=f"{MSG_PREFIX} Taskflow -- {{{{ dag_run.dag_id }}}} ")

with DAG(
    "ses_callback_on_success",
    on_success_callback=_ses_callback,
    tags=["ses"],
):
    sleep_n_secs(1)

with DAG(
    "ses_notifier_as_callback",
    on_success_callback=SesNotifier(**DEFAULTS, subject=f"{MSG_PREFIX} Sync Notifier as callback -- {{{{ dag_run.dag_id }}}} "),
    tags=["ses"],
):
    sleep_n_secs(1)


with DAG(
    "ses_notifier_as_deadline",
    deadline=DeadlineAlert(
        reference=DeadlineReference.FIXED_DATETIME(PAST_DATE),
        interval=timedelta(0),
        callback=AsyncCallback(
            SesNotifier,
            kwargs={**DEFAULTS, "subject": f"{MSG_PREFIX} Async Notifier as Deadline -- {{{{ dag_run.dag_id }}}} "}
        ),
    ),
    tags=["ses"],
):
    sleep_n_secs(1)

and proof that the emails are delivered and templates work:

image

cc; @ramitkataria @seanghaeli


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@boring-cyborg boring-cyborg bot added area:providers provider:amazon AWS/Amazon - related issues labels Sep 25, 2025
@ferruzzi ferruzzi requested a review from vincbeck September 25, 2025 23:21
Copy link
Contributor

@vincbeck vincbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment but overall, looks good 👍

@ferruzzi ferruzzi mentioned this pull request Sep 26, 2025
1 task
@ferruzzi ferruzzi merged commit afa7345 into apache:main Sep 26, 2025
79 checks passed
@ferruzzi ferruzzi deleted the ferruzzi/notifiers/ses branch September 26, 2025 23:34
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Sep 30, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 1, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 2, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 3, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 4, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 5, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 5, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 7, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 8, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 9, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 10, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 11, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 12, 2025
* Add a new Amazon Simple Email Service Notifier
dabla pushed a commit to dabla/airflow that referenced this pull request Oct 12, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 14, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 15, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 17, 2025
* Add a new Amazon Simple Email Service Notifier
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 19, 2025
* Add a new Amazon Simple Email Service Notifier
@zachliu
Copy link
Contributor

zachliu commented Dec 5, 2025

silly question, why aren't we _build_email_content as in the SmtpNotifier

def _build_email_content(self, smtp: SmtpHook, context: Context):

so that they can be drop-in replacement for each other?

@ferruzzi
Copy link
Contributor Author

ferruzzi commented Dec 8, 2025

Silly answer, 🤷

No particular reason. Didn't think of it?

@zachliu
Copy link
Contributor

zachliu commented Dec 8, 2025

lol cool, i'll submit a pr 😜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants