Permalink
Browse files

Added support for HTML emails via format param

  • Loading branch information...
1 parent 3d22adb commit 7e855cfb6c9f00bea3f325e891666c721287f8d4 @hmarr hmarr committed with Mitch Garnaat Jan 25, 2011
Showing with 13 additions and 1 deletion.
  1. +13 −1 boto/ses/__init__.py
View
@@ -71,13 +71,25 @@ def send_email(self, source, subject, body, to_addresses, cc_addresses=None,
:type bcc_addresses: list of strings or string
:param bcc_addresses: The BCC: field(s) of the message.
+ :type format: string
+ :param format: The format of the message's body, must be either "text"
+ or "html".
+
"""
params = {
'Action': 'SendEmail',
'Source': source,
'Message.Subject.Data': subject,
- 'Message.Body.Text.Data': body,
}
+
+ format = format.lower().strip()
+ if format == 'html':
+ params['Message.Body.Html.Data'] = body
+ elif format == 'text':
+ params['Message.Body.Text.Data'] = body
+ else:
+ raise ValueError("'format' argument must be 'text' or 'html'")
+
self.build_list_params(params, to_addresses,
'Destination.ToAddresses.member')
if cc_addresses:

0 comments on commit 7e855cf

Please sign in to comment.