messages.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:hydra 作者: Our-Revolution 项目源码 文件源码
def message(self):
        if not self._message:
            if self.drip_base.from_email_name:
                from_ = "%s <%s>" % (self.drip_base.from_email_name, self.drip_base.from_email)
            else:
                from_ = self.drip_base.from_email

            to_address = [self.context['email_address']] if not isinstance(self.context['email_address'], list) else self.context['email_address']

            self._message = EmailMultiAlternatives(self.subject, self.plain, from_, to_address)

            # check if there are html tags in the rendered template
            if len(self.plain) != len(self.body):

                html_body = self.body

                if self.drip_base.template:
                    html_body = render_to_string(self.drip_base.template, dict(self._data, **{'email_content': html_body}))

                self._message.attach_alternative(html_body, 'text/html')
        return self._message
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号