Send new members a welcome email
This commit is contained in:
parent
a914171cb3
commit
3fd1b016b0
40
apiserver/apiserver/api/emails/welcome.html
Normal file
40
apiserver/apiserver/api/emails/welcome.html
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
<style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>Hi [name],<br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>You just signed up to Spaceport with the username: [username]<br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>To manage your Protospace membership go to:<br></div>
|
||||||
|
<div><a href="https://my.protospace.ca">https://my.protospace.ca</a><br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>You have automatically been added to our forum Spacebar at:<br></div>
|
||||||
|
<div><a href="https://forum.protospace.ca">https://forum.protospace.ca</a><br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>Please introduce yourself here:<br></div>
|
||||||
|
<div><a href="https://forum.protospace.ca/c/chattymcchatface/new-user-introductions/31">https://forum.protospace.ca/c/chattymcchatface/new-user-introductions/31</a><br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>If you have any questions, you will get the fastest response there.<br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>Your next goal is to become vetted after:<br></div>
|
||||||
|
<div>- paying your member dues<br></div>
|
||||||
|
<div>- being a member for four weeks<br></div>
|
||||||
|
<div>- attending a New Member Orientation<br></div>
|
||||||
|
<div>- finding two members to sponsor (vouch for) you<br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>You can meet members Tuesday evenings during our open house.<br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>Mark [date] on your calendar as the day you can get vetted.<br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>Sign up for a New Member Orientation here:<br></div>
|
||||||
|
<div><a href="https://my.protospace.ca/classes">https://my.protospace.ca/classes</a><br></div>
|
||||||
|
<div><br></div>
|
||||||
|
<div>Good luck,<br></div>
|
||||||
|
<div>Spaceport<br></div>
|
||||||
|
<div><br></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
30
apiserver/apiserver/api/emails/welcome.txt
Normal file
30
apiserver/apiserver/api/emails/welcome.txt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
Hi [name],
|
||||||
|
|
||||||
|
You just signed up to Spaceport with the username: [username]
|
||||||
|
|
||||||
|
To manage your Protospace membership go to:
|
||||||
|
https://my.protospace.ca
|
||||||
|
|
||||||
|
You have automatically been added to our forum Spacebar at:
|
||||||
|
https://forum.protospace.ca
|
||||||
|
|
||||||
|
Please introduce yourself here:
|
||||||
|
https://forum.protospace.ca/c/chattymcchatface/new-user-introductions/31
|
||||||
|
|
||||||
|
If you have any questions, you will get the fastest response there.
|
||||||
|
|
||||||
|
Your next goal is to become vetted after:
|
||||||
|
- paying your member dues
|
||||||
|
- being a member for four weeks
|
||||||
|
- attending a New Member Orientation
|
||||||
|
- finding two members to sponsor (vouch for) you
|
||||||
|
|
||||||
|
You can meet members Tuesday evenings during our open house.
|
||||||
|
|
||||||
|
Mark [date] on your calendar as the day you can get vetted.
|
||||||
|
|
||||||
|
Sign up for a New Member Orientation here:
|
||||||
|
https://my.protospace.ca/classes
|
||||||
|
|
||||||
|
Good luck,
|
||||||
|
Spaceport
|
|
@ -21,7 +21,7 @@ from django.db.models import Sum
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.utils.timezone import now, pytz
|
from django.utils.timezone import now, pytz
|
||||||
|
|
||||||
from . import models, serializers, utils_ldap, utils_stats, utils_auth, utils
|
from . import models, serializers, utils_ldap, utils_stats, utils_auth, utils, utils_email
|
||||||
from .. import settings
|
from .. import settings
|
||||||
|
|
||||||
STATIC_FOLDER = 'data/static/'
|
STATIC_FOLDER = 'data/static/'
|
||||||
|
@ -374,6 +374,14 @@ def register_user(data, user):
|
||||||
utils.alert_tanner(msg)
|
utils.alert_tanner(msg)
|
||||||
logger.info(msg)
|
logger.info(msg)
|
||||||
|
|
||||||
|
if data['request_id']: utils_stats.set_progress(data['request_id'], 'Sending welcome email...')
|
||||||
|
try:
|
||||||
|
utils_email.send_welcome_email(user.member)
|
||||||
|
except BaseException as e: # TODO: remove, just for testing
|
||||||
|
msg = 'Problem sending welcome email: ' + str(e)
|
||||||
|
logger.exception(msg)
|
||||||
|
alert_tanner(msg)
|
||||||
|
|
||||||
if data['request_id']: utils_stats.set_progress(data['request_id'], 'Done!')
|
if data['request_id']: utils_stats.set_progress(data['request_id'], 'Done!')
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
46
apiserver/apiserver/api/utils_email.py
Normal file
46
apiserver/apiserver/api/utils_email.py
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
import os
|
||||||
|
import smtplib
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
from django.core.mail import send_mail
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
from .. import settings
|
||||||
|
|
||||||
|
EMAIL_DIR = os.path.join(settings.BASE_DIR, 'apiserver/api/emails/')
|
||||||
|
|
||||||
|
def send_welcome_email(member):
|
||||||
|
vetting_date = member.application_date + timedelta(days=28)
|
||||||
|
|
||||||
|
def replace_fields(text):
|
||||||
|
return text.replace(
|
||||||
|
'[name]', member.first_name,
|
||||||
|
).replace(
|
||||||
|
'[username]', member.user.username,
|
||||||
|
).replace(
|
||||||
|
'[date]', vetting_date.strftime('%A, %B %d'),
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(EMAIL_DIR + 'welcome.txt', 'r') as f:
|
||||||
|
email_text = replace_fields(f.read())
|
||||||
|
|
||||||
|
with open(EMAIL_DIR + 'welcome.html', 'r') as f:
|
||||||
|
email_html = replace_fields(f.read())
|
||||||
|
|
||||||
|
try:
|
||||||
|
send_mail(
|
||||||
|
subject='Welcome to Protospace!',
|
||||||
|
message=email_text,
|
||||||
|
from_email=None, # defaults to DEFAULT_FROM_EMAIL
|
||||||
|
recipient_list=[member.user.email, 'portal@tannercollin.com'],
|
||||||
|
html_message=email_html,
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info('Sent welcome email:\n' + email_text)
|
||||||
|
except smtplib.SMTPException as e:
|
||||||
|
msg = 'Problem sending welcome email to ' + member.user.email + ': ' + str(e)
|
||||||
|
utils.alert_tanner(msg)
|
||||||
|
logger.exception(msg)
|
Loading…
Reference in New Issue
Block a user