Skip to content

Commit

Permalink
Fix SES delivery quirks, esp for html email
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregg Thomason committed Nov 30, 2015
1 parent b3a56a7 commit ee36693
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions flask_passwordless/delivery_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,17 @@ def __call__(self, token, email):

class DeliverBySES(DeliveryMethod):
def __init__(self, config):
# TODO: this can also use the env instead of a config file for keys+id
if "AWS_ACCESS_KEY_ID" not in config:
self.config = config['SMTP']
self.tmpl_config = config['TEMPLATES']
# TODO: this should also use the env instead of a config file for keys+id
if "AWS_ACCESS_KEY_ID" not in self.config:
raise ConfigurationError("You must have an AWS ACCESS KEY in the config.")
if "AWS_SECRET_ACCESS_KEY" not in config:
if "AWS_SECRET_ACCESS_KEY" not in self.config:
raise ConfigurationError("You must have an AWS SECRET ACCESS KEY in the config.")
self.config = config
self.conn = boto.ses.connect_to_region(
'us-west-2',
aws_access_key_id=config['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=config['AWS_SECRET_ACCESS_KEY'])
'us-east-1',
aws_access_key_id=self.config['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=self.config['AWS_SECRET_ACCESS_KEY'])

def __call__(self, token, email):
"""send the login token"""
Expand All @@ -144,12 +145,14 @@ def __call__(self, token, email):
self.from_email,
self.msg_subject,
msg,
[target_email])
[target_email],
html_body=messagetext)


DELIVERY_METHODS = {
'mandrill': DeliverByMandrill,
'smtp': DeliverBySMTP,
'log': DeliverByLog,
'ses': DeliverBySES,
'null': DeliverByNull
}

0 comments on commit ee36693

Please sign in to comment.