Merge pull request #46 from marcus-ahle/master
Adding HTML support for SES send_email()
This commit is contained in:
commit
37cf88c82b
@ -36,7 +36,10 @@ class EmailResponse(BaseResponse):
|
|||||||
return template.render()
|
return template.render()
|
||||||
|
|
||||||
def send_email(self):
|
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]
|
source = self.querystring.get('Source')[0]
|
||||||
subject = self.querystring.get('Message.Subject.Data')[0]
|
subject = self.querystring.get('Message.Subject.Data')[0]
|
||||||
destination = self.querystring.get('Destination.ToAddresses.member.1')[0]
|
destination = self.querystring.get('Destination.ToAddresses.member.1')[0]
|
||||||
|
@ -55,6 +55,20 @@ def test_send_email():
|
|||||||
sent_count = int(send_quota['GetSendQuotaResponse']['GetSendQuotaResult']['SentLast24Hours'])
|
sent_count = int(send_quota['GetSendQuotaResponse']['GetSendQuotaResult']['SentLast24Hours'])
|
||||||
sent_count.should.equal(1)
|
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",
|
||||||
|
"<span>test body</span>", "test_to@example.com", format="html").should.throw(BotoServerError)
|
||||||
|
|
||||||
|
conn.verify_email_identity("test@example.com")
|
||||||
|
conn.send_email("test@example.com", "test subject", "<span>test body</span>", "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
|
@mock_ses
|
||||||
def test_send_raw_email():
|
def test_send_raw_email():
|
||||||
|
Loading…
Reference in New Issue
Block a user