def test_send_email_unicode_subject(self): """Testing sending an EmailMessage with a unicode subject""" email = EmailMessage(subject='\ud83d\ude04', text_body='This is a test', html_body='<p>This is a test</p>', from_email='*****@*****.**', to=['*****@*****.**'], sender='*****@*****.**') with self.settings(EMAIL_BACKEND=_CONSOLE_EMAIL_BACKEND): email.send()
def test_send_with_unicode_subject(self): """Testing EmailMessage.send with a Unicode subject""" email = EmailMessage(subject='\U0001f604', text_body='This is a test', html_body='<p>This is a test</p>', from_email='*****@*****.**', to=['*****@*****.**'], sender='*****@*****.**') with self.settings(EMAIL_BACKEND=_CONSOLE_EMAIL_BACKEND): email.send()
def test_send_email_unicode_body(self): """Testing sending an EmailMessage with a unicode body""" email = EmailMessage(subject='Test email', text_body='\ud83d\ude04', html_body='<p>\ud83d\ude04</p>', from_email='*****@*****.**', to=['*****@*****.**'], sender='*****@*****.**') # If the e-mail doesn't send correctly, it will raise a # UnicodeDecodeError. with self.settings(EMAIL_BACKEND=_CONSOLE_EMAIL_BACKEND): email.send()
def test_send_with_unicode_body(self): """Testing EmailMessage.send with a Unicode body""" email = EmailMessage(subject='Test email', text_body='\U0001f604', html_body='<p>\U0001f604</p>', from_email='*****@*****.**', to=['*****@*****.**'], sender='*****@*****.**') # If the e-mail doesn't send correctly, it will raise a # UnicodeDecodeError. with self.settings(EMAIL_BACKEND=_CONSOLE_EMAIL_BACKEND): email.send()
def test_extra_headers_dict(self): """Testing sending extra headers as a dict with an e-mail message""" email = EmailMessage(subject='Test email', text_body='This is a test.', html_body='<p>This is a test.</p>', from_email='*****@*****.**', to=['*****@*****.**'], headers={ 'X-Foo': 'Bar', }) email.send() self.assertEqual(len(mail.outbox), 1) message = mail.outbox[0] self.assertIn('X-Foo', message._headers) self.assertEqual(message._headers['X-Foo'], 'Bar')
def test_extra_headers_multivalue_dict(self): """Testing sending extra headers as a MultiValueDict with an e-mail message """ header_values = ['Bar', 'Baz'] email = EmailMessage(subject='Test email', text_body='This is a test.', html_body='<p>This is a test.</p>', from_email='*****@*****.**', to=['*****@*****.**'], headers=MultiValueDict({ 'X-Foo': header_values, })) email.send() self.assertEqual(len(mail.outbox), 1) message = mail.outbox[0] self.assertIn('X-Foo', message._headers) self.assertEqual(set(message._headers.getlist('X-Foo')), set(header_values))