Created
October 19, 2014 00:09
-
-
Save camsom/480ddd850fb54f9e7263 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.template.loader import render_to_string | |
import boto | |
from stakeholder.models import * | |
from message.utils import SendEmailMixin | |
CONFIRMATION_SUBJECT = 'Activate your account with NextTier' | |
CONFIRMATION_TEMPLATE = 'email/confirm.txt' | |
CONFIRMATION_TEMPLATE_HTML = 'email/confirm.html' | |
def confirmation_link(stakeholder): | |
base_url = 'https://www.nexttiereducation.com/confirm/' | |
token = RegistrationToken.objects.get(stakeholder=stakeholder).token | |
return base_url + token | |
def send_email(stakeholder): | |
link = confirmation_link(stakeholder) | |
context = { | |
'to_email': stakeholder.email, | |
'confirm_link': link, | |
} | |
html = render_to_string(CONFIRMATION_TEMPLATE_HTML, context) | |
plain_text = render_to_string(CONFIRMATION_TEMPLATE, context) | |
ses_conn = boto.connect_ses( | |
'AKIAIVI3KEAXXLFE235A' | |
,'jZyiv8s1xItdYvnBTV5R+S5snrjxAbLqQ3s8vsw5') | |
try: | |
ses_conn.send_email( | |
'[email protected]', | |
CONFIRMATION_SUBJECT, | |
html, | |
stakeholder.email, | |
text_body=plain_text, | |
format='html' | |
) | |
except BotoServerError as e: | |
print 'could not send email to {0}'.format(stakeholder.email) | |
return | |
def run(): | |
for email in missed_users: | |
st = Stakeholder.objects.get(email=email) | |
if st.verified: | |
continue | |
else: | |
send_email(st) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment