Permalink
Browse files

Merged pull request #172 from vikalp/master.

Fixes for ses send_email method better handling of exceptions
  • Loading branch information...
2 parents bb3c0b1 + 9df1856 commit a758e156d68b6d541f27fda89423e31e090694d3 @garnaat garnaat committed Apr 27, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 boto/ses/connection.py
View
@@ -151,6 +151,7 @@ def send_email(self, source, subject, body, to_addresses, cc_addresses=None,
:param html_body: The html body to send with this email.
"""
+ format = format.lower().strip()
if body is not None:
if format == "text":
if text_body is not None:
@@ -169,14 +170,17 @@ def send_email(self, source, subject, body, to_addresses, cc_addresses=None,
if return_path:
params['ReturnPath'] = return_path
- format = format.lower().strip()
if html_body is not None:
params['Message.Body.Html.Data'] = html_body
if text_body is not None:
params['Message.Body.Text.Data'] = text_body
- else:
+
+ if(format not in ("text","html")):
raise ValueError("'format' argument must be 'text' or 'html'")
+ if(not (html_body and text_body)):
+ raise ValueError("No text or html body found for mail")
+
self._build_list_params(params, to_addresses,
'Destination.ToAddresses.member')
if cc_addresses:

0 comments on commit a758e15

Please sign in to comment.