def test_send_mail(self):
    'Check compose form.'
    url = '{}?action=compose'.format(reverse('modoboa_webmail:index'))
    response = self.client.get(url)
    self.assertEqual(response.status_code, 200)
    response = self.client.post(url, {'from_': self.user.email, 'to': 'example@example.com', 'subject': 'test', 'body': 'Test'})
    self.assertEqual(len(mail.outbox), 1)
    self.assertEqual(mail.outbox[0].from_email, 'example@example.com')
    self.user.first_name = 'Antoine'
    self.user.last_name = 'Nguyen'
    self.user.parameters.set_value('editor', 'html')
    self.user.save()
    response = self.client.get(url)
    self.assertEqual(response.status_code, 200)
    mail.outbox = []
    response = self.client.post(url, {'from_': self.user.email, 'to': 'example@example.com', 'subject': 'test', 'body': '<p>Test</p>'})
    self.assertEqual(len(mail.outbox), 1)
    self.assertEqual(mail.outbox[0].from_email, '"Antoine Nguyen" <example@example.com>')
Check compose form.
def test_send_mail(self):
    
    url = '{}?action=compose'.format(reverse('modoboa_webmail:index'))
    response = self.client.get(url)
    self.assertEqual(response.status_code, 200)
    response = self.client.post(url, {'from_': self.user.email, 'to': 'example@example.com', 'subject': 'test', 'body': 'Test'})
    self.assertEqual(len(mail.outbox), 1)
    self.assertEqual(mail.outbox[0].from_email, 'example@example.com')
    self.user.first_name = 'Antoine'
    self.user.last_name = 'Nguyen'
    self.user.parameters.set_value('editor', 'html')
    self.user.save()
    response = self.client.get(url)
    self.assertEqual(response.status_code, 200)
    mail.outbox = []
    response = self.client.post(url, {'from_': self.user.email, 'to': 'example@example.com', 'subject': 'test', 'body': '<p>Test</p>'})
    self.assertEqual(len(mail.outbox), 1)
    self.assertEqual(mail.outbox[0].from_email, '"Antoine Nguyen" <example@example.com>')