This is an automated email from the ASF dual-hosted git repository.
eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 115da5b3cd6 Move SendGrid and SES email backend setup docs to their
providers (#71571)
115da5b3cd6 is described below
commit 115da5b3cd678cd906aceebabb6561731b2785fa
Author: Elad Kalif <[email protected]>
AuthorDate: Fri Aug 14 13:43:49 2026 -0400
Move SendGrid and SES email backend setup docs to their providers (#71571)
* Move SendGrid and SES email backend setup docs to their providers
The core email-config how-to mixed general Airflow email configuration
(SMTP, templates, from_email) with full provider-specific setup guides
for SendGrid and Amazon SES, duplicating information that already
belongs with each provider and making the core doc harder to navigate.
Move the provider-specific instructions into a new email-backend page
in each provider's docs, link back to the core doc for the shared
concepts, and have the core doc simply present the email_backend
mechanism with links out to the providers. Also add the missing
:ref: cross-link in the SES emailer docstring, mirroring the one
SendGrid's emailer already had.
* Auto-generate the list of email backends from provider metadata
* fix
* fix
---
airflow-core/docs/howto/email-config.rst | 127 +++------------------
airflow-core/src/airflow/provider.yaml.schema.json | 7 ++
airflow-core/src/airflow/provider_info.schema.json | 7 ++
contributing-docs/12_provider_distributions.rst | 5 +-
dev/breeze/tests/test_packages.py | 1 +
.../src/sphinx_exts/operators_and_hooks_ref.py | 27 +++++
.../templates/email-backends.rst.jinja2 | 29 +++++
.../core-extensions/email-backends.rst | 34 ++++++
providers-summary-docs/index.rst | 11 ++
providers/amazon/docs/email-backend.rst | 62 ++++++++++
providers/amazon/docs/index.rst | 1 +
providers/amazon/provider.yaml | 3 +
.../airflow/providers/amazon/aws/utils/emailer.py | 7 +-
.../airflow/providers/amazon/get_provider_info.py | 1 +
providers/sendgrid/docs/email-backend.rst | 92 +++++++++++++++
providers/sendgrid/docs/index.rst | 7 ++
providers/sendgrid/provider.yaml | 4 +
.../providers/sendgrid/get_provider_info.py | 1 +
18 files changed, 309 insertions(+), 117 deletions(-)
diff --git a/airflow-core/docs/howto/email-config.rst
b/airflow-core/docs/howto/email-config.rst
index c3373447654..4bf43d07d77 100644
--- a/airflow-core/docs/howto/email-config.rst
+++ b/airflow-core/docs/howto/email-config.rst
@@ -50,6 +50,7 @@ Equivalent environment variables look like:
AIRFLOW__EMAIL__FROM_EMAIL="John Doe <[email protected]>"
+By default, ``email_backend`` is set to
``airflow.utils.email.send_email_smtp``, which sends email over SMTP.
To configure SMTP settings, checkout the :ref:`SMTP <config:smtp>` section in
the standard configuration.
If you do not want to store the SMTP credentials in the config or in the
environment variables, you can create a
@@ -57,6 +58,10 @@ connection called ``smtp_default`` of ``Email`` type, or
choose a custom connect
the configuration & store SMTP username-password in it. Other SMTP settings
like host, port etc always gets picked up
from the configuration only. The connection can be of any type (for example
'HTTP connection').
+.. image:: ../img/ui-dark/email_connection.png
+ :align: center
+ :alt: create email connection
+
If you want to check which email backend is currently set, you can use
``airflow config get-value email email_backend`` command as in
the example below.
@@ -80,119 +85,13 @@ For example a ``html_content_template`` file could look
like this:
.. note::
For more information on setting the configuration, see :doc:`set-config`
-.. _email-configuration-sendgrid:
-
-Send email using SendGrid
--------------------------
-
-Using Default SMTP
-^^^^^^^^^^^^^^^^^^
-
-You can use the default Airflow SMTP backend to send email with SendGrid
-
- .. code-block:: ini
-
- [smtp]
- smtp_host=smtp.sendgrid.net
- smtp_starttls=False
- smtp_ssl=False
- smtp_port=587
- smtp_mail_from=<your-from-email>
-
-Equivalent environment variables looks like
-
- .. code-block::
-
- AIRFLOW__SMTP__SMTP_HOST=smtp.sendgrid.net
- AIRFLOW__SMTP__SMTP_STARTTLS=False
- AIRFLOW__SMTP__SMTP_SSL=False
- AIRFLOW__SMTP__SMTP_PORT=587
- AIRFLOW__SMTP__SMTP_MAIL_FROM=<your-from-email>
-
-
-Using SendGrid Provider
-^^^^^^^^^^^^^^^^^^^^^^^
-
-Airflow can be configured to send e-mail using `SendGrid
<https://sendgrid.com/>`__.
-
-Follow the steps below to enable it:
-
-1. Setup your SendGrid account, The SMTP and copy username and API Key.
-
-2. Include ``sendgrid`` provider as part of your Airflow installation, e.g.,
-
- .. code-block:: bash
-
- pip install 'apache-airflow[sendgrid]' --constraint ...
-
-or
- .. code-block:: bash
-
- pip install 'apache-airflow-providers-sendgrid' --constraint ...
-
-
-3. Update ``email_backend`` property in ``[email]`` section in
``airflow.cfg``, i.e.
-
- .. code-block:: ini
-
- [email]
- email_backend = airflow.providers.sendgrid.utils.emailer.send_email
- email_conn_id = sendgrid_default
- from_email = "[email protected]"
-
- Equivalent environment variables looks like
-
- .. code-block::
-
-
AIRFLOW__EMAIL__EMAIL_BACKEND=airflow.providers.sendgrid.utils.emailer.send_email
- AIRFLOW__EMAIL__EMAIL_CONN_ID=sendgrid_default
- [email protected]
-
-4. Create a connection called ``sendgrid_default``, or choose a custom
connection
- name and set it in ``email_conn_id`` of 'Email' type. Only login and
password
- are used from the connection.
-
-
-.. image:: ../img/ui-dark/email_connection.png
- :align: center
- :alt: create email connection
-
-.. note:: The callbacks for success, failure and retry will use the same
configuration to send the email
-
-
-.. _email-configuration-ses:
-
-Send email using AWS SES
-------------------------
-
-Airflow can be configured to send e-mail using `AWS SES
<https://aws.amazon.com/ses/>`__.
-
-Follow the steps below to enable it:
-
-1. Include ``amazon`` subpackage as part of your Airflow installation:
-
- .. code-block:: ini
-
- pip install 'apache-airflow[amazon]'
-
-2. Update ``email_backend`` property in ``[email]`` section in ``airflow.cfg``:
-
- .. code-block:: ini
-
- [email]
- email_backend = airflow.providers.amazon.aws.utils.emailer.send_email
- email_conn_id = aws_default
- from_email = From email <[email protected]>
-
- Equivalent environment variables looks like
-
- .. code-block::
-
-
AIRFLOW__EMAIL__EMAIL_BACKEND=airflow.providers.amazon.aws.utils.emailer.send_email
- AIRFLOW__EMAIL__EMAIL_CONN_ID=aws_default
- [email protected]
+Alternative email backends
+---------------------------
-Note that for SES, you must configure from_email to the valid email that can
send messages from SES.
+Instead of sending email over SMTP, you can point ``email_backend`` at an
implementation provided by a
+community provider to send email through a third-party service's API. To use
one, install the relevant
+provider distribution, set ``email_backend`` to the dotted path of its
``send_email`` function, and set
+``email_conn_id`` to a connection holding the credentials it needs.
-3. Create a connection called ``aws_default``, or choose a custom connection
- name and set it in ``email_conn_id``. The type of connection should be
``Amazon Web Services``.
+The list of email backends provided by community-managed providers is
available in
+:doc:`apache-airflow-providers:core-extensions/email-backends`.
diff --git a/airflow-core/src/airflow/provider.yaml.schema.json
b/airflow-core/src/airflow/provider.yaml.schema.json
index d1b0651c670..a8a08c4d71e 100644
--- a/airflow-core/src/airflow/provider.yaml.schema.json
+++ b/airflow-core/src/airflow/provider.yaml.schema.json
@@ -590,6 +590,13 @@
"type": "string"
}
},
+ "email-backends": {
+ "type": "array",
+ "description": "Email backend function names",
+ "items": {
+ "type": "string"
+ }
+ },
"auth-managers": {
"type": "array",
"description": "Auth managers class names",
diff --git a/airflow-core/src/airflow/provider_info.schema.json
b/airflow-core/src/airflow/provider_info.schema.json
index 4e6ddacebd1..63085abca16 100644
--- a/airflow-core/src/airflow/provider_info.schema.json
+++ b/airflow-core/src/airflow/provider_info.schema.json
@@ -324,6 +324,13 @@
"type": "string"
}
},
+ "email-backends": {
+ "type": "array",
+ "description": "Email backend function names",
+ "items": {
+ "type": "string"
+ }
+ },
"logging": {
"type": "array",
"description": "Logging Task Handlers class names",
diff --git a/contributing-docs/12_provider_distributions.rst
b/contributing-docs/12_provider_distributions.rst
index 639d0c014cd..c7a234aaf05 100644
--- a/contributing-docs/12_provider_distributions.rst
+++ b/contributing-docs/12_provider_distributions.rst
@@ -89,8 +89,9 @@ This file contains:
* description of the distribution that is available in the documentation
* list of versions of distribution that have been released so far
* list of integrations, operators, hooks, sensors, transfers provided by the
provider (useful for documentation generation)
-* list of connection types, extra-links, secret backends, auth backends, and
logging handlers (useful to both
- register them as they are needed by Airflow and to include them in
documentation automatically).
+* list of connection types, extra-links, secret backends, auth backends, email
backends, and logging
+ handlers (useful to both register them as they are needed by Airflow and to
include them in
+ documentation automatically).
Note that the ``provider.yaml`` file is regenerated automatically when the
provider is released so you should
not modify it - except updating dependencies, as your changes will be lost.
diff --git a/dev/breeze/tests/test_packages.py
b/dev/breeze/tests/test_packages.py
index 60ded346be4..ce136d70b87 100644
--- a/dev/breeze/tests/test_packages.py
+++ b/dev/breeze/tests/test_packages.py
@@ -376,6 +376,7 @@ def test_get_provider_info_dict():
assert len(provider_info_dict["connection-types"]) > 3
assert len(provider_info_dict["notifications"]) > 2
assert len(provider_info_dict["secrets-backends"]) > 1
+ assert len(provider_info_dict["email-backends"]) > 0
assert len(provider_info_dict["logging"]) > 1
assert len(provider_info_dict["config"].keys()) > 1
assert len(provider_info_dict["executors"]) > 0
diff --git a/devel-common/src/sphinx_exts/operators_and_hooks_ref.py
b/devel-common/src/sphinx_exts/operators_and_hooks_ref.py
index d2c86f6de98..097e2029df0 100644
--- a/devel-common/src/sphinx_exts/operators_and_hooks_ref.py
+++ b/devel-common/src/sphinx_exts/operators_and_hooks_ref.py
@@ -402,6 +402,19 @@ class LoggingDirective(BaseJinjaReferenceDirective):
)
+class EmailBackendsDirective(BaseJinjaReferenceDirective):
+ """Generate list of email backends"""
+
+ def render_content(
+ self, *, tags: set[str] | None, header_separator: str =
DEFAULT_HEADER_SEPARATOR
+ ) -> str:
+ return _common_render_list_content(
+ header_separator=header_separator,
+ resource_type="email-backends",
+ template="email-backends.rst.jinja2",
+ )
+
+
class AuthConfigurations(BaseJinjaReferenceDirective):
"""Generate list of configurations"""
@@ -553,6 +566,7 @@ def setup(app):
app.add_directive("operators-hooks-ref", OperatorsHooksReferenceDirective)
app.add_directive("transfers-ref", TransfersReferenceDirective)
app.add_directive("airflow-logging", LoggingDirective)
+ app.add_directive("airflow-email-backends", EmailBackendsDirective)
app.add_directive("airflow-configurations", AuthConfigurations)
app.add_directive("airflow-secrets-backends", SecretsBackendDirective)
app.add_directive("airflow-connections", ConnectionsDirective)
@@ -625,6 +639,19 @@ def secret_backends(header_separator: str):
)
[email protected]()
+@option_header_separator
+def email_backends(header_separator: str):
+ """Renders Email Backends content"""
+ print(
+ _common_render_list_content(
+ header_separator=header_separator,
+ resource_type="email-backends",
+ template="email-backends.rst.jinja2",
+ )
+ )
+
+
@cli.command()
@option_header_separator
def connections(header_separator: str):
diff --git a/devel-common/src/sphinx_exts/templates/email-backends.rst.jinja2
b/devel-common/src/sphinx_exts/templates/email-backends.rst.jinja2
new file mode 100644
index 00000000000..3eaa36301ff
--- /dev/null
+++ b/devel-common/src/sphinx_exts/templates/email-backends.rst.jinja2
@@ -0,0 +1,29 @@
+{#
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+#}
+{%for provider, provider_dict in items.items() %}
+{{ provider_dict['name'] }}
+{{ header_separator * (provider_dict['name']|length) }}
+
+:doc:`{{ provider }}:email-backend`
+
+{% for backend in provider_dict['email-backends'] -%}
+- :func:`~{{ backend }}`
+{% endfor -%}
+
+{% endfor %}
diff --git a/providers-summary-docs/core-extensions/email-backends.rst
b/providers-summary-docs/core-extensions/email-backends.rst
new file mode 100644
index 00000000000..94efdbfc344
--- /dev/null
+++ b/providers-summary-docs/core-extensions/email-backends.rst
@@ -0,0 +1,34 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ .. http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+Email backends
+---------------
+
+This is a summary of all Apache Airflow Community provided implementations of
email backends
+exposed via community-managed providers.
+
+Airflow can send email (for example, task success/failure/retry callbacks)
through a pluggable
+``email_backend`` instead of the default SMTP implementation, letting a
provider send that email
+through a third-party service's API.
+
+You can read about the general email configuration mechanism in
+:doc:`apache-airflow:howto/email-config` and here you can see the email
backends
+provided by the community-managed providers:
+
+.. airflow-email-backends::
+ :tags: None
+ :header-separator: "
diff --git a/providers-summary-docs/index.rst b/providers-summary-docs/index.rst
index a4ddca7dfba..1a5db2ef503 100644
--- a/providers-summary-docs/index.rst
+++ b/providers-summary-docs/index.rst
@@ -128,6 +128,17 @@ You can see all the notifications available via
community-managed providers in
:doc:`/core-extensions/notifications`.
+Email backends
+''''''''''''''
+
+Airflow can send email (for example, task success/failure/retry callbacks)
through a pluggable
+``email_backend`` instead of the default SMTP implementation. Providers can
add email backends that
+send that email through a third-party service's API.
+
+You can see all the email backends available via community-managed providers in
+:doc:`/core-extensions/email-backends`.
+
+
Installing and upgrading providers
----------------------------------
diff --git a/providers/amazon/docs/email-backend.rst
b/providers/amazon/docs/email-backend.rst
new file mode 100644
index 00000000000..4f2fdc9684f
--- /dev/null
+++ b/providers/amazon/docs/email-backend.rst
@@ -0,0 +1,62 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ .. http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+.. _email-configuration-ses:
+
+Send email using AWS SES
+==========================
+
+Airflow can be configured to send e-mail using `AWS SES
<https://aws.amazon.com/ses/>`__ as the
+``email_backend``, so that task callback emails (success, failure, retry) go
out through SES instead
+of SMTP. See :doc:`apache-airflow:howto/email-config` for the general Airflow
email configuration this
+page builds on.
+
+.. note::
+
+ If you instead want to send an email as a Dag task, use the
+ :ref:`SesEmailOperator <howto/operator:SesEmailOperator>` documented in
:doc:`operators/ses`.
+
+Follow the steps below to enable it:
+
+1. Install the ``amazon`` provider as part of your Airflow installation:
+
+ .. code-block:: bash
+
+ pip install 'apache-airflow[amazon]'
+
+2. Update the ``[email]`` section in ``airflow.cfg``:
+
+ .. code-block:: ini
+
+ [email]
+ email_backend = airflow.providers.amazon.aws.utils.emailer.send_email
+ email_conn_id = aws_default
+ from_email = From email <[email protected]>
+
+ Equivalent environment variables look like:
+
+ .. code-block:: sh
+
+
AIRFLOW__EMAIL__EMAIL_BACKEND=airflow.providers.amazon.aws.utils.emailer.send_email
+ AIRFLOW__EMAIL__EMAIL_CONN_ID=aws_default
+ [email protected]
+
+ ``from_email`` is required and must be a sender address verified with SES.
+
+3. Create a connection called ``aws_default``, or choose a custom connection
name and set it in
+ ``email_conn_id``, of type ``Amazon Web Services``. See
:doc:`apache-airflow:howto/connection` for
+ how to create a connection.
diff --git a/providers/amazon/docs/index.rst b/providers/amazon/docs/index.rst
index 7dc10574bd4..971df9b7ef1 100644
--- a/providers/amazon/docs/index.rst
+++ b/providers/amazon/docs/index.rst
@@ -35,6 +35,7 @@
Bundles <bundles/index>
Connection types <connections/index>
+ Email backend <email-backend>
Notifications <notifications/index>
Operators <operators/index>
Transfers <transfer/index>
diff --git a/providers/amazon/provider.yaml b/providers/amazon/provider.yaml
index 20feaede66c..8bab7657c06 100644
--- a/providers/amazon/provider.yaml
+++ b/providers/amazon/provider.yaml
@@ -1129,6 +1129,9 @@ secrets-backends:
- airflow.providers.amazon.aws.secrets.secrets_manager.SecretsManagerBackend
-
airflow.providers.amazon.aws.secrets.systems_manager.SystemsManagerParameterStoreBackend
+email-backends:
+ - airflow.providers.amazon.aws.utils.emailer.send_email
+
logging:
- airflow.providers.amazon.aws.log.s3_task_handler.S3TaskHandler
-
airflow.providers.amazon.aws.log.cloudwatch_task_handler.CloudwatchTaskHandler
diff --git a/providers/amazon/src/airflow/providers/amazon/aws/utils/emailer.py
b/providers/amazon/src/airflow/providers/amazon/aws/utils/emailer.py
index 5b4ffd30c0a..26165530509 100644
--- a/providers/amazon/src/airflow/providers/amazon/aws/utils/emailer.py
+++ b/providers/amazon/src/airflow/providers/amazon/aws/utils/emailer.py
@@ -38,7 +38,12 @@ def send_email(
custom_headers: dict[str, Any] | None = None,
**kwargs,
) -> None:
- """Email backend for SES."""
+ """
+ Email backend for SES.
+
+ .. note::
+ For more information, see :ref:`email-configuration-ses`
+ """
if from_email is None:
raise RuntimeError("The `from_email' configuration has to be set for
the SES emailer.")
hook = SesHook(aws_conn_id=conn_id)
diff --git a/providers/amazon/src/airflow/providers/amazon/get_provider_info.py
b/providers/amazon/src/airflow/providers/amazon/get_provider_info.py
index 8e249e606fe..ea3e1f49437 100644
--- a/providers/amazon/src/airflow/providers/amazon/get_provider_info.py
+++ b/providers/amazon/src/airflow/providers/amazon/get_provider_info.py
@@ -1254,6 +1254,7 @@ def get_provider_info():
"airflow.providers.amazon.aws.secrets.secrets_manager.SecretsManagerBackend",
"airflow.providers.amazon.aws.secrets.systems_manager.SystemsManagerParameterStoreBackend",
],
+ "email-backends":
["airflow.providers.amazon.aws.utils.emailer.send_email"],
"logging": [
"airflow.providers.amazon.aws.log.s3_task_handler.S3TaskHandler",
"airflow.providers.amazon.aws.log.cloudwatch_task_handler.CloudwatchTaskHandler",
diff --git a/providers/sendgrid/docs/email-backend.rst
b/providers/sendgrid/docs/email-backend.rst
new file mode 100644
index 00000000000..d1920222e1a
--- /dev/null
+++ b/providers/sendgrid/docs/email-backend.rst
@@ -0,0 +1,92 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ .. http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+.. _email-configuration-sendgrid:
+
+Send email using SendGrid
+==========================
+
+Airflow can be configured to send e-mail using `SendGrid
<https://sendgrid.com/>`__, either through
+its SMTP relay or through this provider's API-based backend. See
:doc:`apache-airflow:howto/email-config`
+for the general Airflow email configuration this page builds on.
+
+Using Default SMTP
+-------------------
+
+You can use the default Airflow SMTP backend to send email with SendGrid
without installing this provider:
+
+.. code-block:: ini
+
+ [smtp]
+ smtp_host=smtp.sendgrid.net
+ smtp_starttls=False
+ smtp_ssl=False
+ smtp_port=587
+ smtp_mail_from=<your-from-email>
+
+Equivalent environment variables look like:
+
+.. code-block:: sh
+
+ AIRFLOW__SMTP__SMTP_HOST=smtp.sendgrid.net
+ AIRFLOW__SMTP__SMTP_STARTTLS=False
+ AIRFLOW__SMTP__SMTP_SSL=False
+ AIRFLOW__SMTP__SMTP_PORT=587
+ AIRFLOW__SMTP__SMTP_MAIL_FROM=<your-from-email>
+
+Using the SendGrid Provider
+-----------------------------
+
+To send email through SendGrid's API instead, follow the steps below:
+
+1. Set up your SendGrid account, then locate your SMTP username and API Key.
+
+2. Install the ``sendgrid`` provider as part of your Airflow installation,
e.g.:
+
+ .. code-block:: bash
+
+ pip install 'apache-airflow[sendgrid]' --constraint ...
+
+ or
+
+ .. code-block:: bash
+
+ pip install 'apache-airflow-providers-sendgrid' --constraint ...
+
+3. Update the ``[email]`` section in ``airflow.cfg``:
+
+ .. code-block:: ini
+
+ [email]
+ email_backend = airflow.providers.sendgrid.utils.emailer.send_email
+ email_conn_id = sendgrid_default
+ from_email = "[email protected]"
+
+ Equivalent environment variables look like:
+
+ .. code-block:: sh
+
+
AIRFLOW__EMAIL__EMAIL_BACKEND=airflow.providers.sendgrid.utils.emailer.send_email
+ AIRFLOW__EMAIL__EMAIL_CONN_ID=sendgrid_default
+ [email protected]
+
+4. Create a connection called ``sendgrid_default``, or choose a custom
connection name and set it in
+ ``email_conn_id``, of ``Email`` type. Only the login and password fields
are used from the connection;
+ set the password field to your SendGrid API Key. See
:doc:`apache-airflow:howto/connection` for how
+ to create a connection.
+
+.. note:: The callbacks for success, failure and retry will use the same
configuration to send the email.
diff --git a/providers/sendgrid/docs/index.rst
b/providers/sendgrid/docs/index.rst
index f1b519e391e..12e89acb5d1 100644
--- a/providers/sendgrid/docs/index.rst
+++ b/providers/sendgrid/docs/index.rst
@@ -29,6 +29,13 @@
Changelog <changelog>
Security <security>
+.. toctree::
+ :hidden:
+ :maxdepth: 1
+ :caption: Guides
+
+ Email backend <email-backend>
+
.. toctree::
:hidden:
:maxdepth: 1
diff --git a/providers/sendgrid/provider.yaml b/providers/sendgrid/provider.yaml
index 522ae6350ba..170c602d2d5 100644
--- a/providers/sendgrid/provider.yaml
+++ b/providers/sendgrid/provider.yaml
@@ -24,6 +24,10 @@ description: |
state: ready
lifecycle: production
source-date-epoch: 1780426378
+
+email-backends:
+ - airflow.providers.sendgrid.utils.emailer.send_email
+
# Note that those versions are maintained by release manager - do not update
them manually
# with the exception of case where other provider in sources has >= new
provider version.
# In such case adding >= NEW_VERSION and bumping to NEW_VERSION in a provider
have
diff --git
a/providers/sendgrid/src/airflow/providers/sendgrid/get_provider_info.py
b/providers/sendgrid/src/airflow/providers/sendgrid/get_provider_info.py
index 513779cd22e..d97e67595b2 100644
--- a/providers/sendgrid/src/airflow/providers/sendgrid/get_provider_info.py
+++ b/providers/sendgrid/src/airflow/providers/sendgrid/get_provider_info.py
@@ -26,4 +26,5 @@ def get_provider_info():
"package-name": "apache-airflow-providers-sendgrid",
"name": "Sendgrid",
"description": "`Sendgrid <https://sendgrid.com/>`__\n",
+ "email-backends":
["airflow.providers.sendgrid.utils.emailer.send_email"],
}