mirror of
https://github.com/workhardbekind/workout-challenge.git
synced 2026-07-04 09:23:32 -04:00
first commit
This commit is contained in:
commit
e7f627801f
152 changed files with 35352 additions and 0 deletions
23
src-backend/custom_user/emails/multipurpose.py
Normal file
23
src-backend/custom_user/emails/multipurpose.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import os
|
||||
from django.conf import settings
|
||||
from django.core.mail import get_connection
|
||||
from django.core.mail.message import EmailMultiAlternatives
|
||||
|
||||
|
||||
|
||||
def send_email(subject, body, to_email, cc=[], reply_to=[]):
|
||||
"""General function via which all emails are sent out"""
|
||||
to_email = [settings.EMAIL_FROM] if (settings.DEBUG or '.local' in to_email.lower()) else [to_email]
|
||||
from_email = settings.EMAIL_FROM
|
||||
reply_to_email = ([from_email] if settings.EMAIL_REPLY_TO is None else settings.EMAIL_REPLY_TO) if reply_to == [] else reply_to
|
||||
|
||||
print(f'Email Server: {settings.EMAIL_HOST}')
|
||||
connection = get_connection()
|
||||
mail = EmailMultiAlternatives(
|
||||
subject=subject, body="", from_email=from_email, to=to_email, cc=cc, reply_to=reply_to_email, connection=connection
|
||||
)
|
||||
mail.attach_alternative(body, "text/html")
|
||||
mail.content_subtype = "html"
|
||||
|
||||
mail.send()
|
||||
print(f'Email "{subject}" sent to {to_email}')
|
||||
Loading…
Add table
Add a link
Reference in a new issue