Hi,
I need to send failure notifications from composer DAGs. I have created an app password for gmail smtp. Following is the composer config override configuration. I created the password in secret manager.
smtp
smtp_port
587
smtp_timeout
30
smtp_mail_from
h******@gmail.com
smtp_host
smtp_starttls
True
smtp_ssl
False
smtp_retry_limit
5
smtp_user
h******@gmail.com
smtp_password_secret
smtp-password
email_backend
airflow.utils.email.send_email_smtp
I am getting the following error after running the DAG
Error
2022-02-01T15:23:27.361324593Z
airflow-worker (530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError mv10sm3097322pjb.45 - gsmtp', 'h*******@gmail.com')
textPayload
(530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError mv10sm3097322pjb.45 - gsmtp', 'h****@gmail.com')
However, when I run the following python code, it sends the email successfully
import smtplib, ssl
smtp_server = "smtp.gmail.com"
port = 25#587# For starttls
sender_email = "h***@gmail.com"
receiver_email = "h***@gmail.com"
password = "******"#input("Type your password and press enter: ")
message = "hello"
# Create a secure SSL context
context = ssl.create_default_context()
# Try to log in to server and send email
try:
with smtplib.SMTP(smtp_server, port) as server:
server = smtplib.SMTP(smtp_server,port)
server.ehlo() # Can be omitted
server.starttls(context=context) # Secure the connection
server.ehlo() # Can be omitted
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)
# TODO: Send email here
except Exception as e:
# Print any error messages to stdout
print(e)
finally:
server.quit()
I tried all possible changes I could think of, deleting secret and editing the airflow.cfg directly to set the smtp config, changing values of config each, but nothing helped . Would appreciate any help, as I am completely stuck on this.
--
You received this message because you are subscribed to the Google Groups "cloud-composer-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-composer-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-composer-discuss/55ee7c24-7319-4ac4-b9c0-432336e74fcdn%40googlegroups.com.
File "/opt/python3.6/lib/python3.6/smtplib.py", line 721, in login
initial_response_ok=initial_response_ok)
File "/opt/python3.6/lib/python3.6/smtplib.py", line 642, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials 38sm33300640pgm.37 - gsmtp')
[2022-02-02 06:26:26,419] {local_task_job.py:159} WARNING - State of this instance has been externally set to failed. Taking the poison pill.
[2022-02-02 06:26:26,421] {helpers.py:325} INFO - Sending Signals.SIGTERM to GPID 1325
[2022-02-02 06:26:26,554] {helpers.py:291} INFO - Process psutil.Process(pid=1325, status='terminated', exitcode=1, started='06:26:20') (1325) terminated with exit code 1
[2022-02-02 06:26:26,556] {local_task_job.py:102} INFO - Task exited with return code 1
Thanks,