135 lines
3.8 KiB
Python
135 lines
3.8 KiB
Python
from app.notifications.aws.aws_mailer import send_email_ses
|
|
from app.utils.logger import logger
|
|
|
|
|
|
def send_email_factory(to_email, subject, html_content, text_content=None):
|
|
try:
|
|
send_email_ses(
|
|
to_email=to_email,
|
|
subject=subject,
|
|
html_content=body_template(html_content)
|
|
)
|
|
|
|
except Exception as e:
|
|
logger.error(f"Send_Email_Factory failed: {e}")
|
|
raise
|
|
|
|
|
|
def alert_email_factory(to_email, subject, html_content, text_content=None):
|
|
try:
|
|
send_email_ses(
|
|
to_email=to_email,
|
|
subject=subject,
|
|
html_content=alert_template(html_content)
|
|
)
|
|
|
|
except Exception as e:
|
|
logger.error(f"Alert_Email_Factory failed: {e}")
|
|
raise
|
|
|
|
|
|
def body_template(html_content):
|
|
html_body = f"""\
|
|
<html>
|
|
<head></head>
|
|
<body style="font-size:14px;line-height:1.5;">
|
|
|
|
<div style="
|
|
font-family: 'Public Sans', helvetica, arial, sans-serif;
|
|
max-width: 480px; margin: 0 auto; padding: 16px;
|
|
color: #1b1b1b; font-size: 16px; line-height: 1.5;
|
|
background-color: #ffffff;">
|
|
|
|
<div style="text-align: center; padding: 16px 0 24px 0;">
|
|
<img src="https://www.mermsemr.com/images/logo-pink.png"
|
|
alt="MermsEmr"
|
|
height="40" />
|
|
</div>
|
|
|
|
|
|
<div style="border: 1px solid #dfe1e2; border-radius: 8px; padding: 20px 24px; margin-bottom: 24px;">
|
|
<div style="font-weight: 700; font-size: 18px; margin-bottom: 16px;">
|
|
{html_content}
|
|
</div>
|
|
</div>
|
|
|
|
<p style="margin: 0 0 16px 0;">
|
|
For any support<br>
|
|
Reach Out<br>
|
|
support@mermsemr.com<br>
|
|
https://www.mermsemr.com/
|
|
</p>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
"""
|
|
return html_body
|
|
|
|
|
|
def alert_template(html_content):
|
|
html_body = f"""\
|
|
<html>
|
|
<head></head>
|
|
<body style="font-size:14px;line-height:1.5;">
|
|
<table width="550px" border="0" cellpadding="3" cellspacing="3" background-color="#F0F8FF" style="font-size:16px">
|
|
<tr>
|
|
<td style="text-align:center">
|
|
<img style="width:150px; height:auto;" src="https://www.mermsemr.com/images/logo-pink.png" />
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
{html_content}
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<br />
|
|
LINKS --- ---- ---- -----
|
|
<br />
|
|
For any support<br>
|
|
Reach Out<br>
|
|
support@mermsemr.com<br>
|
|
https://www.mermsemr.com/
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
"""
|
|
return html_body
|
|
|
|
# < table
|
|
# width = "550px"
|
|
# border = "0"
|
|
# cellpadding = "3"
|
|
# cellspacing = "3"
|
|
# background - color = "#F0F8FF"
|
|
# style = "font-size:16px" >
|
|
# < tr >
|
|
# < td
|
|
# style = "text-align:center" >
|
|
# < img
|
|
# style = "width:150px; height:auto;"
|
|
# src = "https://www.mermsemr.com/images/logo-pink.png" / >
|
|
# < / td >
|
|
# < / tr >
|
|
# < tr >
|
|
# < td >
|
|
# {html_content}
|
|
# < / td >
|
|
# < / tr >
|
|
#
|
|
# < tr >
|
|
# < td >
|
|
# For
|
|
# any
|
|
# support < br >
|
|
# Reach
|
|
# Out < br >
|
|
# support @ mermsemr.com < br >
|
|
# https: // www.mermsemr.com /
|
|
# < / td >
|
|
# < / tr >
|
|
# < / table > |