Skip to content

Commit

Permalink
Add missing email type of connection (#18502)
Browse files Browse the repository at this point in the history
The email configuration of Airflow became somwhat hybrid - part
of the configuration is in the config file and part (authentication)
in connection. However there is no dedicated connection type to
use for email, and user got confused - they did not realize they
could use any connection, and this was really not intuitive.

This PR adds email connection type as built-in and updates the
documentation of email configuration to use that connection
type for smtp/sendgrid (and use the aws one for aws email)

Fixes: #18495
  • Loading branch information
potiuk authored Sep 24, 2021
1 parent ac4acf9 commit be82001
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3297,6 +3297,7 @@ def _get_connection_types() -> List[Tuple[str, str]]:
_connection_types = [
('fs', 'File (path)'),
('mesos_framework-id', 'Mesos Framework ID'),
('email', 'Email'),
]
providers_manager = ProvidersManager()
for connection_type, provider_info in providers_manager.hooks.items():
Expand Down
19 changes: 13 additions & 6 deletions docs/apache-airflow/howto/email-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ in the ``[email]`` section.
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
connection called ``smtp_default``, or choose a custom connection name and set the ``email_conn_id`` with it's name in
connection called ``smtp_default`` of ``Email`` type, or choose a custom connection name and set the ``email_conn_id`` with it's name in
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').

Expand Down Expand Up @@ -67,11 +67,17 @@ Airflow can be configured to send e-mail using `SendGrid <https://sendgrid.com/>

Follow the steps below to enable it:

1. Include ``sendgrid`` subpackage as part of your Airflow installation, e.g.,
1. Include ``sendgrid`` provider as part of your Airflow installation, e.g.,

.. code-block:: ini
.. code-block:: bash
pip install 'apache-airflow[sendgrid]' --constraint ...
or
.. code-block:: bash
pip install 'apache-airflow-providers-sendgrid' --constraint ...
pip install 'apache-airflow[sendgrid]'
2. Update ``email_backend`` property in ``[email]`` section in ``airflow.cfg``, i.e.

Expand All @@ -82,7 +88,8 @@ Follow the steps below to enable it:
email_conn_id = sendgrid_default
3. Create a connection called ``sendgrid_default``, or choose a custom connection
name and set it in ``email_conn_id``.
name and set it in ``email_conn_id`` of 'Email' type. Only login and password
are used from the connection.

.. _email-configuration-ses:

Expand All @@ -108,4 +115,4 @@ Follow the steps below to enable it:
email_conn_id = aws_default
3. Create a connection called ``aws_default``, or choose a custom connection
name and set it in ``email_conn_id``.
name and set it in ``email_conn_id``. The type of connection should be ``Amazon Web Services``.

0 comments on commit be82001

Please sign in to comment.