def build_message(self): """ Returns an :class:`EmailMultiAlternatives` instance. """ self.email_context = self.get_email_context() subject = self.get_subject() html_body = self.get_body() from_email = self.get_from_email() to = self.get_to_addresses() plain_body = html_to_plain(html_body) msg = self.email_message_class(subject, body, from_email, to) if self.use_html: msg.attach_alternative(html_body, "text/html") return msg
def test_html_to_plain(self): test_text = """<p><a href="http://google.com">Google</a> can be useful sometimes.</p>""" self.assertEqual(html_to_plain(test_text), "Google can be useful sometimes.")