How can I send smtp via http proxy in Airflow?

Viewed 106

I'm trying to send email on failure in Airflow. Airflow is in a offline server and it needs the forward proxy to smtp server, but there is no such configuration. I already set HTTP_PROXY, HTTPS_PROXY in ~/.bashrc, but not working

# ~/.bashrc

...
proxy=http://hh.hh.hh.hh:pppp
export HTTP_PROXY=$proxy
export HTTPS_PROXY=$proxy
export http_proxy=$proxy
export https_proxy=$proxy
[smtp]

smtp_host = smtp.office365.com
smtp_starttls = True
...
# no such configuration!
# proxy = hh.hh.hh.hh:pppp

In source code of Airflow, it seems to use smtplib, so i tried

import smtplib
import socks

proxy_host = 'hh.hh.hh.hh'
proxy_port = pppp

socks.setdefaultproxy(socks.PROXY_TYPE_HTTP, proxy_host, proxy_port)
socks.wrapmodule(smtplib)
# -> airflow webserver get ImportError

How can i set forward proxy here?

0 Answers
Related