mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-10 15:17:44 +00:00
31 lines
723 B
Python
31 lines
723 B
Python
"""
|
|
Common send_mail function
|
|
"""
|
|
import logging
|
|
|
|
from django.core.mail import EmailMultiAlternatives
|
|
|
|
|
|
def send_mail(subject, message, from_email, recipient_list, html_message=None, cc=None,
|
|
fail_silently=False):
|
|
"""
|
|
Send Email
|
|
:param subject:
|
|
:param message:
|
|
:param from_email:
|
|
:param recipient_list:
|
|
:param html_message:
|
|
:param cc:
|
|
:param fail_silently:
|
|
:return:
|
|
"""
|
|
try:
|
|
mail = EmailMultiAlternatives(subject, message, from_email, recipient_list, cc)
|
|
if html_message:
|
|
mail.attach_alternative(html_message, 'text/html')
|
|
|
|
return mail.send(fail_silently)
|
|
except Exception as e:
|
|
logging.error(e)
|
|
return False
|