airflow-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reed Villanueva <rvillanu...@ucera.org>
Subject Re: EmailOperator throws SMTPException(“STARTTLS extension not supported by server.”)
Date Tue, 15 Oct 2019 23:47:17 GMT
Thanks for the info.
The script you wrote worked when commenting out the “s.starttls” line and
using the email From address that the working sendmail bash script already
uses was successful in sending an email out.
When using this from-address as the smtp_mail_from param in the airflow.cfg
file, nothing seems to have changed.

Would I need to edit the airflow source code as well (to comment out the
“s.starttls”  line in the file identified in the traceback)? Do I need to
restart the webserver? What exactly do you think is going on here that made
you think of that debugging test script?



On Tue, Oct 15, 2019 at 11:35 AM Shaw, Damian P. <
damian.shaw.2@credit-suisse.com> wrote:

> If you’re using localhost you probably don’t need TLS, but you can test
> with plain Python code if you can send an email using the default settings
> you describe below:
>
>
>
> # Import smtplib for the actual sending function
>
> import smtplib
>
> from email.mime.text import MIMEText
>
>
>
> send_to = 'rvillanueva@ucera.org'
>
> msg = MIMEText('Hello World')
>
> msg['Subject'] = 'Test Airflow Email'
>
> msg['From'] = 'airflow@example.com'
>
> msg['To'] = send_to
>
>
>
> # SMTP Send
>
> s = smtplib.SMTP('localhost')
>
> s.starttls() # Try commenting out this line and see if you get a different
> error
>
> s.sendmail(me, [send_to], msg.as_string())
>
> s.quit()
>
>
>
> If commenting out “s.starttls” produces a new error try changing the
> “From” to whatever you see that sendmail shows as sending from. Once you
> have a Python script working you can update the airflow.cfg to the same
> settings.
>
>
>
> *From:* Reed Villanueva [mailto:rvillanueva@ucera.org]
> *Sent:* Tuesday, October 15, 2019 5:02 PM
> *To:* users@airflow.apache.org
> *Subject:* EmailOperator throws SMTPException(“STARTTLS extension not
> supported by server.”)
>
>
>
> Trying to use airflow's EmailOperator to send an email on
> trigger_rule.ONE_FAILED and seeing error:
>
> [2019-10-14 13:31:50,604] {configuration.py:206} WARNING - section/key [smtp/smtp_user]
not found in config
>
> Traceback (most recent call last):
>
>    File "/bin/airflow", line 27, in <module>
>
> [     args.func(args)
>
>    File "/usr/lib/python2.7/site-packages/airflow/bin/cli.py", line 392, in run
>
>      pool=args.pool,
>
>    File "/usr/lib/python2.7/site-packages/airflow/utils/db.py", line 50, in wrapper
>
>      result = func(*args, **kwargs)
>
>    File "/usr/lib/python2.7/site-packages/airflow/models.py", line 1493, in _run_raw_task
>
>      result = task_copy.execute(context=context)
>
>    File "/usr/lib/python2.7/site-packages/airflow/operators/email_operator.py", line
64, in execute
>
>      send_email(self.to, self.subject, self.html_content, files=self.files, cc=self.cc,
bcc=self.bcc, mime_subtype=self.mime_subtype)
>
>    File "/usr/lib/python2.7/site-packages/airflow/utils/email.py", line 44, in send_email
>
>      return backend(to, subject, html_content, files=files, dryrun=dryrun, cc=cc, bcc=bcc,
mime_subtype=mime_subtype)
>
>    File "/usr/lib/python2.7/site-packages/airflow/utils/email.py", line 87, in send_email_smtp
>
>      send_MIME_email(SMTP_MAIL_FROM, recipients, msg, dryrun)
>
>    File "/usr/lib/python2.7/site-packages/airflow/utils/email.py", line 109, in send_MIME_email
>
>      s.starttls()
>
>    File "/usr/lib64/python2.7/smtplib.py", line 643, in starttls
>
>      raise SMTPException("STARTTLS extension not supported by server.")
>
>  smtplib.SMTPException: STARTTLS
>
> Have not changed the default airflow.cfg (other than for basic password
> authentication to access the webserver) and the email portion looks like
>
> [email]
>
> email_backend = airflow.utils.email.send_email_smtp
>
>
>
>
>
> [smtp]
>
> # If you want airflow to send emails on retries, failure, and you want to use
>
> # the airflow.utils.email.send_email_smtp function, you have to configure an
>
> # smtp server here
>
> smtp_host = localhost
>
> smtp_starttls = True
>
> smtp_ssl = False
>
> # Uncomment and set the user/pass settings if you want to use SMTP AUTH
>
> # smtp_user = airflow
>
> # smtp_password = airflow
>
> smtp_port = 25
>
> smtp_mail_from = airflow@example.com
>
> Checking the port in the cfg file, it seems to be open and listening...
>
> [rvillanueva@mapr001 queensetl_airflow]$ netstat -plnt | grep ':25'
>
> (Not all processes could be identified, non-owned process info
>
>  will not be shown, you would have to be root to see it all.)
>
> tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      -
>
> tcp6       0      0 ::1:25                  :::*                    LISTEN      -
>
> ... and I am able to use the linux sendmail bash command for other
> process that run on this same machine (CentOS 7).
>
> Anyone know what could be going on here or any further debugging tips?
>
>
> This electronic message is intended only for the named
> recipient, and may contain information that is confidential or
> privileged. If you are not the intended recipient, you are
> hereby notified that any disclosure, copying, distribution or
> use of the contents of this message is strictly prohibited. If
> you have received this message in error or are not the named
> recipient, please notify us immediately by contacting the
> sender at the electronic mail address noted above, and delete
> and destroy all copies of this message. Thank you.
>
>
>
>
> ==============================================================================
> Please access the attached hyperlink for an important electronic
> communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>
> ==============================================================================
>

-- 
This electronic message is intended only for the named 
recipient, and may 
contain information that is confidential or 
privileged. If you are not the 
intended recipient, you are 
hereby notified that any disclosure, copying, 
distribution or 
use of the contents of this message is strictly 
prohibited. If 
you have received this message in error or are not the 
named
recipient, please notify us immediately by contacting the 
sender at 
the electronic mail address noted above, and delete 
and destroy all copies 
of this message. Thank you.

Mime
View raw message