airflow-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaw, Damian P. " <>
Subject RE: EmailOperator throws SMTPException(“STARTTLS extension not supported by server.”)
Date Tue, 15 Oct 2019 21:34:38 GMT
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 = ''
msg = MIMEText('Hello World')
msg['Subject'] = 'Test Airflow Email'
msg['From'] = ''
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())

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 []
Sent: Tuesday, October 15, 2019 5:02 PM
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

[2019-10-14 13:31:50,604] {} 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/", line 392, in run


   File "/usr/lib/python2.7/site-packages/airflow/utils/", line 50, in wrapper

     result = func(*args, **kwargs)

   File "/usr/lib/python2.7/site-packages/airflow/", line 1493, in _run_raw_task

     result = task_copy.execute(context=context)

   File "/usr/lib/python2.7/site-packages/airflow/operators/", line 64, in

     send_email(, self.subject, self.html_content, files=self.files,, bcc=self.bcc,

   File "/usr/lib/python2.7/site-packages/airflow/utils/", line 44, in send_email

     return backend(to, subject, html_content, files=files, dryrun=dryrun, cc=cc, bcc=bcc,

   File "/usr/lib/python2.7/site-packages/airflow/utils/", line 87, in send_email_smtp

     send_MIME_email(SMTP_MAIL_FROM, recipients, msg, dryrun)

   File "/usr/lib/python2.7/site-packages/airflow/utils/", line 109, in send_MIME_email


   File "/usr/lib64/python2.7/", 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_backend =


# If you want airflow to send emails on retries, failure, and you want to use

# the 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 =<>

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

View raw message