refactor(chalice): changed email_handler.py

This commit is contained in:
Taha Yassine Kraiem 2024-02-26 12:31:36 +01:00
parent c56bda106d
commit 91016cf92d

View file

@ -13,10 +13,6 @@ from chalicelib.utils import smtp
logger = logging.getLogger(__name__)
def __get_subject(subject):
return subject
def __get_html_from_file(source, formatting_variables):
if formatting_variables is None:
formatting_variables = {}
@ -53,7 +49,7 @@ def send_html(BODY_HTML, SUBJECT, recipient, bcc=None):
if not isinstance(recipient, list):
recipient = [recipient]
msg = MIMEMultipart()
msg['Subject'] = Header(__get_subject(SUBJECT), 'utf-8')
msg['Subject'] = Header(SUBJECT, 'utf-8')
msg['From'] = config("EMAIL_FROM")
msg['To'] = ""
body = MIMEText(BODY_HTML.encode('utf-8'), 'html', "utf-8")
@ -78,7 +74,7 @@ def send_html(BODY_HTML, SUBJECT, recipient, bcc=None):
def send_text(recipients, text, subject):
with smtp.SMTPClient() as s:
msg = MIMEMultipart()
msg['Subject'] = Header(__get_subject(subject), 'utf-8')
msg['Subject'] = Header(subject, 'utf-8')
msg['From'] = config("EMAIL_FROM")
msg['To'] = ", ".join(recipients)
body = MIMEText(text)