potiuk commented on pull request #16166:
URL: https://github.com/apache/airflow/pull/16166#issuecomment-873394140


   > @uranusjr currently we have smtp, sendgrid and aws SES as airflow backend. 
Sendgrid and smtp backend are using SENDGRID_MAIL_FROM and SMTP_MAIL_FROM 
environment variables respectively for "from" email. Should we create 
environment variable SES_MAIL_FROM for this (as per pattern)? cc - @mik-laj
   
   While this is likely not perfect, I think it's better to make it consistent.
   
   This is what sendgrid uses currently:
   
   ```
   from_email = kwargs.get('from_email') or os.environ.get('SENDGRID_MAIL_FROM')
   from_name = kwargs.get('from_name') or 
os.environ.get('SENDGRID_MAIL_SENDER')**
   ````
   
   It allows for  both kwargs and environment variables set, but with standard 
emails sent by airflow (alert/sla) the kwargs are not used anyway.  However the 
documentation in 
https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/email-config.rst
 does not mention those env vars. It mentions few other '[email]' options but 
it does not mention any of the [smtp] options which are used by the standard 
"send_email_smtp" backend.
   
   ```
   [smtp]
   smtp_user = airflow
   smtp_password = airflow
   smtp_mail_from = [email protected]
   ```
   
   So we have a bit of a mess to be honest. Proposal: 
   
   How about making it consistent and update the documentation at the same time 
between the three backends.
   
   For all backends we could use:
   
   SMTP:
   
   ```
   from_email = kwargs.get('from_email') or os.environ.get('SMTP_MAIL_FROM') or 
conf.get('smtp', 'smtp_mail_from')
   from_name = kwargs.get('from_name') or os.environ.get('SMTP_MAIL_SENDER') or 
conf.get('smtp', 'smtp_mail_sender')
   ```
   SENDGRID:
   
   ```
   from_email = kwargs.get('from_email') or 
os.environ.get('SENDGRID_MAIL_FROM') or conf.get('sendgrid', 
'sendgrid_mail_from')
   from_name = kwargs.get('from_name') or 
os.environ.get('SENDGRID_MAIL_SENDER') or conf.get('sendgrid', 
'sendgrid_mail_sender')
   ```
   
   SES:
   
   ```
   from_email = kwargs.get('from_email') or os.environ.get('SES_MAIL_FROM') or 
conf.get('ses', 'ses_mail_from')
   from_name = kwargs.get('from_name') or os.environ.get('SES_MAIL_SENDER') or 
conf.get('ses', 'ses_mail_sender')
   ```
   
   And update the email documentation about it (also mentioning that you need 
the corresponding providers to use it?


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to