Set up email

This commit is contained in:
Zak Timson 2017-09-15 15:54:05 -04:00
parent ef69d57661
commit 16f0b4ce7e
2 changed files with 10 additions and 1 deletions

View File

@ -27,6 +27,12 @@ DEBUG = False
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['*']
# https://accounts.google.com/DisplayUnlockCaptcha
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'zaktimson@gmail.com'
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 587
# Application definition # Application definition

View File

@ -1,9 +1,11 @@
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.contrib import auth from django.contrib import auth
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core import mail
from charter_members.models import Attorney from charter_members.models import Attorney
from newsletters.models import Subscriber from newsletters.models import Subscriber
from OACPL import settings
def index(request): def index(request):
@ -25,7 +27,8 @@ def login(request):
email=request.POST.get('email'), email=request.POST.get('email'),
password=request.POST.get('password')) password=request.POST.get('password'))
user.save() user.save()
# TODO: Send confirmation email if settings.EMAIL_HOST:
mail.send_mail('OACPL Registration', 'You have successfully registered to the Ontario Asscocaition of Child Protection Lawyers!', settings.EMAIL_HOST_USER, [request.POST.get('email')])
if request.POST.get('newsletter'): if request.POST.get('newsletter'):
Subscriber.objects.create(email=request.POST.get('email')) Subscriber.objects.create(email=request.POST.get('email'))
# TODO: If Case law access was requested, send an email out to staff # TODO: If Case law access was requested, send an email out to staff