From 611b820e3dc1dd0f631e2d167b534614332d6fdf Mon Sep 17 00:00:00 2001 From: Marcus Ahle Date: Wed, 25 Sep 2013 13:51:49 -0400 Subject: [PATCH 1/2] Adding HTML support for SES send_email() --- moto/ses/responses.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/moto/ses/responses.py b/moto/ses/responses.py index 5002f925c..6640d76be 100644 --- a/moto/ses/responses.py +++ b/moto/ses/responses.py @@ -36,7 +36,10 @@ class EmailResponse(BaseResponse): return template.render() def send_email(self): - body = self.querystring.get('Message.Body.Text.Data')[0] + bodydatakey = 'Message.Body.Text.Data' + if 'Message.Body.Html.Data' in self.querystring: + bodydatakey = 'Message.Body.Html.Data' + body = self.querystring.get(bodydatakey)[0] source = self.querystring.get('Source')[0] subject = self.querystring.get('Message.Subject.Data')[0] destination = self.querystring.get('Destination.ToAddresses.member.1')[0] From 766fed9767228014395d5a56c5ec5dbb14c067c9 Mon Sep 17 00:00:00 2001 From: Marcus Ahle Date: Thu, 26 Sep 2013 09:17:38 -0400 Subject: [PATCH 2/2] Adding test for sending html email --- tests/test_ses/test_ses.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_ses/test_ses.py b/tests/test_ses/test_ses.py index 4c0440c40..6b8f357df 100644 --- a/tests/test_ses/test_ses.py +++ b/tests/test_ses/test_ses.py @@ -54,7 +54,21 @@ def test_send_email(): send_quota = conn.get_send_quota() sent_count = int(send_quota['GetSendQuotaResponse']['GetSendQuotaResult']['SentLast24Hours']) sent_count.should.equal(1) + +@mock_ses +def test_send_html_email(): + conn = boto.connect_ses('the_key', 'the_secret') + conn.send_email.when.called_with( + "test@example.com", "test subject", + "test body", "test_to@example.com", format="html").should.throw(BotoServerError) + + conn.verify_email_identity("test@example.com") + conn.send_email("test@example.com", "test subject", "test body", "test_to@example.com", format="html") + + send_quota = conn.get_send_quota() + sent_count = int(send_quota['GetSendQuotaResponse']['GetSendQuotaResult']['SentLast24Hours']) + sent_count.should.equal(1) @mock_ses def test_send_raw_email():