96 lines
2.8 KiB
Python
96 lines
2.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;">
|
|
<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>
|
|
</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
|