コード例 #1
0
ファイル: filebased.py プロジェクト: msvbg/flask-email
    def test_file_sessions(self):
        """Make sure opening a connection creates a new file"""
        msg = EmailMessage('Subject', 'Content', '*****@*****.**', ['*****@*****.**'], headers={'From': '*****@*****.**'})
        connection = get_connection()
        connection.send_messages([msg])

        self.assertEqual(len(os.listdir(self.tmp_dir)), 1)
        message = message_from_file(open(os.path.join(self.tmp_dir, os.listdir(self.tmp_dir)[0])))
        self.assertEqual(message.get_content_type(), 'text/plain')
        self.assertEqual(message.get('subject'), 'Subject')
        self.assertEqual(message.get('from'), '*****@*****.**')
        self.assertEqual(message.get('to'), '*****@*****.**')

        connection2 = get_connection()
        connection2.send_messages([msg])
        self.assertEqual(len(os.listdir(self.tmp_dir)), 2)

        connection.send_messages([msg])
        self.assertEqual(len(os.listdir(self.tmp_dir)), 2)

        msg.connection = get_connection()
        self.assertTrue(connection.open())
        msg.send()
        self.assertEqual(len(os.listdir(self.tmp_dir)), 3)
        msg.send()
        self.assertEqual(len(os.listdir(self.tmp_dir)), 3)
コード例 #2
0
    def test_file_sessions(self):
        """Make sure opening a connection creates a new file"""
        msg = EmailMessage('Subject',
                           'Content',
                           '*****@*****.**', ['*****@*****.**'],
                           headers={'From': '*****@*****.**'})
        connection = get_connection()
        connection.send_messages([msg])

        self.assertEqual(len(os.listdir(self.tmp_dir)), 1)
        message = message_from_file(
            open(os.path.join(self.tmp_dir,
                              os.listdir(self.tmp_dir)[0])))
        self.assertEqual(message.get_content_type(), 'text/plain')
        self.assertEqual(message.get('subject'), 'Subject')
        self.assertEqual(message.get('from'), '*****@*****.**')
        self.assertEqual(message.get('to'), '*****@*****.**')

        connection2 = get_connection()
        connection2.send_messages([msg])
        self.assertEqual(len(os.listdir(self.tmp_dir)), 2)

        connection.send_messages([msg])
        self.assertEqual(len(os.listdir(self.tmp_dir)), 2)

        msg.connection = get_connection()
        self.assertTrue(connection.open())
        msg.send()
        self.assertEqual(len(os.listdir(self.tmp_dir)), 3)
        msg.send()
        self.assertEqual(len(os.listdir(self.tmp_dir)), 3)
コード例 #3
0
ファイル: __init__.py プロジェクト: msvbg/flask-email
 def test_send_verbose_name(self):
     email = EmailMessage("Subject", "Content", '"Firstname Sürname" <*****@*****.**>',
                          ["*****@*****.**"])
     email.send()
     message = self.get_the_message()
     self.assertEqual(message["subject"], "Subject")
     self.assertEqual(message.get_payload(), "Content")
     self.assertEqual(message["from"], "=?utf-8?q?Firstname_S=C3=BCrname?= <*****@*****.**>")
コード例 #4
0
 def test_send_verbose_name(self):
     email = EmailMessage("Subject", "Content", '"Firstname Sürname" <*****@*****.**>',
                          ["*****@*****.**"])
     email.send()
     message = self.get_the_message()
     self.assertEqual(message["subject"], "Subject")
     self.assertEqual(message.get_payload(), "Content")
     self.assertEqual(message["from"], "=?utf-8?q?Firstname_S=C3=BCrname?= <*****@*****.**>")
コード例 #5
0
ファイル: __init__.py プロジェクト: msvbg/flask-email
    def test_idn_send(self):
        """
        Regression test for Django #14301
        """
        self.assertTrue(send_mail('Subject', 'Content', 'from@öäü.com', ['to@öäü.com']))
        message = self.get_the_message()
        self.assertEqual(message.get('subject'), 'Subject')
        self.assertEqual(message.get('from'), '*****@*****.**')
        self.assertEqual(message.get('to'), '*****@*****.**')

        self.flush_mailbox()
        m = EmailMessage('Subject', 'Content', 'from@öäü.com',
                     ['to@öäü.com'], cc=['cc@öäü.com'])
        m.send()
        message = self.get_the_message()
        self.assertEqual(message.get('subject'), 'Subject')
        self.assertEqual(message.get('from'), '*****@*****.**')
        self.assertEqual(message.get('to'), '*****@*****.**')
        self.assertEqual(message.get('cc'), '*****@*****.**')
コード例 #6
0
    def test_idn_send(self):
        """
        Regression test for Django #14301
        """
        self.assertTrue(send_mail('Subject', 'Content', 'from@öäü.com', [u'to@öäü.com']))
        message = self.get_the_message()
        self.assertEqual(message.get('subject'), 'Subject')
        self.assertEqual(message.get('from'), '*****@*****.**')
        self.assertEqual(message.get('to'), '*****@*****.**')

        self.flush_mailbox()
        m = EmailMessage('Subject', 'Content', 'from@öäü.com',
                     [u'to@öäü.com'], cc=[u'cc@öäü.com'])
        m.send()
        message = self.get_the_message()
        self.assertEqual(message.get('subject'), 'Subject')
        self.assertEqual(message.get('from'), '*****@*****.**')
        self.assertEqual(message.get('to'), '*****@*****.**')
        self.assertEqual(message.get('cc'), '*****@*****.**')