diff --git a/helios/utils.py b/helios/utils.py index 2db3dd772f27c9cc378688cbf629b3472cd6ea78..d053dc11fec961d94b6edeee4879826107622d5c 100644 --- a/helios/utils.py +++ b/helios/utils.py @@ -6,7 +6,8 @@ Ben Adida - ben@adida.net """ import urllib, re, sys, datetime, urlparse, string -import threading + +import boto.ses # utils from helios_auth, too from helios_auth.utils import * @@ -154,8 +155,8 @@ from django.core import mail as django_mail def send_email(sender, recpt_lst, subject, body): # subject up until the first newline subject = subject.split("\n")[0] + django_mail.send_mail(subject, body, sender, recpt_lst, fail_silently=True) - ## diff --git a/helios/views.py b/helios/views.py index 388fa99e3106831ede74c715a3237fd54c472994..44002dafc68765e60dcbf2164eb144ce33d7b841 100644 --- a/helios/views.py +++ b/helios/views.py @@ -447,7 +447,7 @@ Your trustee dashboard is at Helios """ % (election.name, url) - send_mail('your trustee homepage for %s' % election.name, body, settings.SERVER_EMAIL, ["%s <%s>" % (trustee.name, trustee.email)], fail_silently=True) + helios_utils.send_email(settings.SERVER_EMAIL, ["%s <%s>" % (trustee.name, trustee.email)], 'your trustee homepage for %s' % election.name, body) logging.info("URL %s " % url) return HttpResponseRedirect(settings.SECURE_URL_HOST + reverse(list_trustees_view, args = [election.uuid])) diff --git a/requirements.txt b/requirements.txt index 02d47dce17742e18525077a724628defc36283f3..fa99dcffc067dfcf93370f7f9dd67d72167c7f45 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,3 +20,5 @@ webtest==2.0.7 django-db-pool==0.0.10 django-secure==0.1.2 bleach==1.4 +boto==2.27.0 +django-ses==0.6.0 diff --git a/settings.py b/settings.py index 5c90c6a36ecfb5e8a7524b7b3ef78a89904d18ea..9734e438850edefd28f9dc45e0ee63a84134badd 100644 --- a/settings.py +++ b/settings.py @@ -231,6 +231,12 @@ EMAIL_HOST_USER = get_from_env('EMAIL_HOST_USER', '') EMAIL_HOST_PASSWORD = get_from_env('EMAIL_HOST_PASSWORD', '') EMAIL_USE_TLS = (get_from_env('EMAIL_USE_TLS', '0') == '1') +# to use AWS Simple Email Service +# in which case environment should contain +# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY +if get_from_env('EMAIL_USE_AWS', '0') == '1': + EMAIL_BACKEND = 'django_ses.SESBackend' + # set up logging import logging logging.basicConfig(