You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/09/06 09:01:19 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #18042: Fixing ses email backend

uranusjr commented on a change in pull request #18042:
URL: https://github.com/apache/airflow/pull/18042#discussion_r702731319



##########
File path: airflow/providers/amazon/aws/utils/emailer.py
##########
@@ -35,9 +37,22 @@ def send_email(
     **kwargs,
 ) -> None:
     """Email backend for SES."""
+    from_email = kwargs.get('from_email') or os.environ.get('SES_MAIL_FROM')
+    if not from_email and conf.has_option('ses', 'ses_mail_from'):
+        from_email = conf.get('ses', 'ses_mail_from')
+
+    from_name = kwargs.get('from_name') or os.environ.get('SES_MAIL_SENDER')
+    if not from_name and conf.has_option('ses', 'ses_mail_sender'):
+        from_name = conf.get('ses', 'ses_mail_sender')
+
+    if from_email:
+        mail_from = formataddr((from_name, from_email))
+    else:
+        mail_from = None
+
     hook = SESHook(aws_conn_id=conn_id)
     hook.send_email(
-        mail_from=None,
+        mail_from=mail_from,

Review comment:
       Wouldn’t think have the exact same error if none of the above were set? I feel we should raise an exception right here if `mail_from` is None so it’s moer obvious to debug.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org