Repository: incubator-airflow Updated Branches: refs/heads/master 4609f689c -> 55af3e04f
[AIRFLOW-626][AIRFLOW-1] HTML Content does not show up when sending email with attachment Closes #1880 from illop/send_email_mimetype Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/55af3e04 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/55af3e04 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/55af3e04 Branch: refs/heads/master Commit: 55af3e04f8aa2062715370c8feec10308938715e Parents: 4609f68 Author: Ilya Rakoshes <il...@wepay.com> Authored: Mon Nov 14 13:44:46 2016 -0800 Committer: Chris Riccomini <chr...@wepay.com> Committed: Mon Nov 14 13:44:46 2016 -0800 ---------------------------------------------------------------------- airflow/operators/email_operator.py | 4 +++- airflow/utils/email.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/55af3e04/airflow/operators/email_operator.py ---------------------------------------------------------------------- diff --git a/airflow/operators/email_operator.py b/airflow/operators/email_operator.py index 76cc56b..5167a7a 100644 --- a/airflow/operators/email_operator.py +++ b/airflow/operators/email_operator.py @@ -49,6 +49,7 @@ class EmailOperator(BaseOperator): files=None, cc=None, bcc=None, + mime_subtype='mixed', *args, **kwargs): super(EmailOperator, self).__init__(*args, **kwargs) self.to = to @@ -57,6 +58,7 @@ class EmailOperator(BaseOperator): self.files = files or [] self.cc = cc self.bcc = bcc + self.mime_subtype = mime_subtype def execute(self, context): - send_email(self.to, self.subject, self.html_content, files=self.files, cc=self.cc, bcc=self.bcc) + send_email(self.to, self.subject, self.html_content, files=self.files, cc=self.cc, bcc=self.bcc, mime_subtype=self.mime_subtype) http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/55af3e04/airflow/utils/email.py ---------------------------------------------------------------------- diff --git a/airflow/utils/email.py b/airflow/utils/email.py index 6fe8662..c4906fd 100644 --- a/airflow/utils/email.py +++ b/airflow/utils/email.py @@ -33,17 +33,17 @@ from email.utils import formatdate from airflow import configuration -def send_email(to, subject, html_content, files=None, dryrun=False, cc=None, bcc=None): +def send_email(to, subject, html_content, files=None, dryrun=False, cc=None, bcc=None, mime_subtype='mixed'): """ Send email using backend specified in EMAIL_BACKEND. """ path, attr = configuration.get('email', 'EMAIL_BACKEND').rsplit('.', 1) module = importlib.import_module(path) backend = getattr(module, attr) - return backend(to, subject, html_content, files=files, dryrun=dryrun, cc=cc, bcc=bcc) + return backend(to, subject, html_content, files=files, dryrun=dryrun, cc=cc, bcc=bcc, mime_subtype=mime_subtype) -def send_email_smtp(to, subject, html_content, files=None, dryrun=False, cc=None, bcc=None): +def send_email_smtp(to, subject, html_content, files=None, dryrun=False, cc=None, bcc=None, mime_subtype='mixed'): """ Send an email with html content @@ -53,7 +53,7 @@ def send_email_smtp(to, subject, html_content, files=None, dryrun=False, cc=None to = get_email_address_list(to) - msg = MIMEMultipart('alternative') + msg = MIMEMultipart(mime_subtype) msg['Subject'] = subject msg['From'] = SMTP_MAIL_FROM msg['To'] = ", ".join(to)