Mubashir Ali
Mubashir Ali

Reputation: 79

How to send an email in AWS MWAA (Apache Airflow) using EmailOperator

I am working with AWS MWAA (Apache Airflow). I want to send an email in MWAA upon completion of my pipeline.I have set the following configuration enter image description here

Now when I run my dag using an Email Operator, it gives me an error.

  File "/usr/lib64/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib64/python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
[2022-05-19, 11:11:21 UTC] {{local_task_job.py:154}} INFO - Task exited with return code 1
[2022-05-19, 11:11:21 UTC] {{local_task_job.py:264}} INFO - 0 downstream tasks scheduled from follow-on schedule check

Then I changed my configuration to enter image description here

It now gives the following error

  File "/usr/lib64/python3.7/smtplib.py", line 642, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (530, b'Must issue a STARTTLS command first')
[2022-05-19, 12:22:39 UTC] {{local_task_job.py:154}} INFO - Task exited with return code 1
[2022-05-19, 12:22:39 UTC] {{local_task_job.py:264}} INFO - 0 downstream tasks scheduled from follow-on schedule check

Can you please tell me where I am doing wrong or how should I configure this to send an email to a particular email address from any domain?

Upvotes: 1

Views: 1591

Answers (1)

ferrouswheel
ferrouswheel

Reputation: 3786

Your smtp host variable is an email address and not a host.

It should be smtp.gmail.com not [email protected]

You've hopefully also changed your password as you have shared it publicly in that screenshot and anyone could use it now.

Upvotes: 1

Related Questions