kolfild26 opened a new issue, #54690:
URL: https://github.com/apache/airflow/issues/54690

   ### Apache Airflow version
   
   3.0.4
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   I have a working smtp & email setup for v.2.10. I recently ran v.3.0.4 but 
unable to use this smtp server.
   What's happening ⬇️
   
   ### What you think should happen instead?
   
   _No response_
   
   ### How to reproduce
   
   Since v.3, Airflow forces you to set up a connection for SMTP - either 
`smtp_default` or the one defined in `AIRFLOW__EMAIL__EMAIL_CONN_ID`.
   
   1. If I don't create a connection, I get the following errors:
   
   ```
   AirflowException: SMTP connection is not found.
   AirflowNotFoundException: The conn_id `smtp_default` isn't defined
   ```
   
   2. Then I create a connection, and since our SMTP server allows using 
without specifying a username and password, I leave these fields empty.
   
   <img width="784" height="693" alt="Image" 
src="https://github.com/user-attachments/assets/4475ce43-4a92-45f0-8410-5188263c6ce1";
 />
   
   All other settings come from environment variables:
   ```
       AIRFLOW__EMAIL__EMAIL_BACKEND: 'airflow.utils.email.send_email_smtp'
       AIRFLOW__EMAIL__EMAIL_CONN_ID: 'smtp_default'
       AIRFLOW__EMAIL__FROM_EMAIL: '[email protected]'
       AIRFLOW__SMTP__SMTP_HOST: 'my.correct.smtphost'
       AIRFLOW__SMTP__SMTP_STARTTLS: 'true'
       AIRFLOW__SMTP__SMTP_SSL: 'false'
       AIRFLOW__SMTP__SMTP_PORT: 25
       AIRFLOW__SMTP__SMTP_MAIL_FROM: '[email protected]'
       AIRFLOW__SMTP__SMTP_TIMEOUT: 30
       AIRFLOW__SMTP__SMTP_RETRY_LIMIT: 5
   ```
   
   After that, create and run a task with EmailOperator:
   
   `SMTPServerDisconnected: please run connect() first`
   ```
   File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py",
 line 890 in run
   File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py",
 line 1177 in _execute_task
   File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/operator.py",
 line 397 in wrapper
   File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/smtp/operators/smtp.py",
 line 89 in execute
   File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/smtp/hooks/smtp.py",
 line 72 in __enter__
   File 
"/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/smtp/hooks/smtp.py",
 line 100 in get_conn
   File "/usr/local/lib/python3.12/smtplib.py", line 769 in starttls
   File "/usr/local/lib/python3.12/smtplib.py", line 611 in 
ehlo_or_helo_if_needed
   File "/usr/local/lib/python3.12/smtplib.py", line 451 in ehlo
   File "/usr/local/lib/python3.12/smtplib.py", line 378 in putcmd
   File "/usr/local/lib/python3.12/smtplib.py", line 365 in send
   ```
   
   If I messed up anything, please guide me on the correct way to set up an 
SMTP in v.3.0.*.
   Thanks in advance!
   
   ### Operating System
   
   OEL9
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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