def test_send_html_email(self):
        mailer = Mailer(self._smtp_host, self._smtp_port)
        text = u"This is the bloody test body"
        html = u"<p>This is the bloody test body</p>"
        mailer.send_html_email("*****@*****.**", "*****@*****.**",
                               "test subject", text, html)

        message = list(self.controller)[0]
        (from_str, from_cs) = decode_header(message["From"])[0]
        (to_str, to_cs) = decode_header(message["To"])[0]
        (subject_str, subject_cs) = decode_header(message["Subject"])[0]

        self.assertEqual("*****@*****.**", from_str)
        self.assertEqual("*****@*****.**", to_str)
        self.assertEqual("test subject", subject_str)
        self.assertEqual(
            text,
            text_type(
                message.get_payload(0).get_payload(decode=True),
                message.get_payload(0).get_content_charset()))
        self.assertEqual("text/plain",
                         message.get_payload(0).get_content_type())
        self.assertEqual(
            html,
            text_type(
                message.get_payload(1).get_payload(decode=True),
                message.get_payload(1).get_content_charset()))
        self.assertEqual("text/html",
                         message.get_payload(1).get_content_type())
Exemple #2
0
    def test_send_email(self):
        mailer = Mailer("localhost", 9025)
        body = "This is the bloody test body"
        mailer.send_email("*****@*****.**", "*****@*****.**", "test subject", body)

        message = list(self.controller)[0]
        (from_str, from_cs) = decode_header(message["From"])[0]
        (to_str, to_cs) = decode_header(message["To"])[0]
        (subject_str, subject_cs) = decode_header(message["Subject"])[0]

        self.assertEqual("*****@*****.**", from_str)
        self.assertEqual("*****@*****.**", to_str)
        self.assertEqual("test subject", subject_str)
        self.assertEqual(body, unicode(message.get_payload(decode=True),
                                       message.get_content_charset()))
    def test_send_email(self):
        mailer = Mailer(self._smtp_host, self._smtp_port)
        body = "This is the bloody test body"
        mailer.send_email("*****@*****.**", "*****@*****.**",
                          "test subject", body)

        message = list(self.controller)[0]
        (from_str, from_cs) = decode_header(message["From"])[0]
        (to_str, to_cs) = decode_header(message["To"])[0]
        (subject_str, subject_cs) = decode_header(message["Subject"])[0]

        self.assertEqual("*****@*****.**", from_str)
        self.assertEqual("*****@*****.**", to_str)
        self.assertEqual("test subject", subject_str)
        self.assertEqual(
            body,
            text_type(message.get_payload(decode=True),
                      message.get_content_charset()))
Exemple #4
0
    def test_send_html_email(self):
        mailer = Mailer("localhost", 9025)
        text = u"This is the bloody test body"
        html = u"<p>This is the bloody test body</p>"
        mailer.send_html_email("*****@*****.**", "*****@*****.**", "test subject", text, html)

        message = list(self.controller)[0]
        (from_str, from_cs) = decode_header(message["From"])[0]
        (to_str, to_cs) = decode_header(message["To"])[0]
        (subject_str, subject_cs) = decode_header(message["Subject"])[0]

        self.assertEqual("*****@*****.**", from_str)
        self.assertEqual("*****@*****.**", to_str)
        self.assertEqual("test subject", subject_str)
        self.assertEqual(text, unicode(message.get_payload(0).get_payload(decode=True),
                                       message.get_payload(0).get_content_charset()))
        self.assertEqual("text/plain", message.get_payload(0).get_content_type())
        self.assertEqual(html, unicode(message.get_payload(1).get_payload(decode=True),
                                       message.get_payload(1).get_content_charset()))
        self.assertEqual("text/html", message.get_payload(1).get_content_type())