-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathemail.py
22 lines (18 loc) · 877 Bytes
/
email.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import logging
from django.core.mail import send_mail
from django.template.loader import render_to_string
from .localizations import fi
from django.conf import settings
def send_confirmation_mail(event, attendee, template):
setting_key = 'ILMO_EMAIL_TEMPLATE_PATH'
template_path = getattr(settings, setting_key)
if not template_path:
logging.error('setting %s was not set so confirmation emails are not sent' % setting_key)
return
msg_html = render_to_string('%s/%s.html' % (template_path, template),
dict(event=event, attendee=attendee))
send_mail(subject=fi.registrationEmailSubject,
message=msg_html,
from_email=getattr(settings, 'DEFAULT_FROM_EMAIL', '[email protected]'),
html_message=msg_html,
recipient_list=[attendee.attendee_email])