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
评论列表
文章目录