From 379734fd6ba2bc54cbd8077af3a3ccc60cc24407 Mon Sep 17 00:00:00 2001 From: Jimmy Jiang Date: Fri, 17 Nov 2023 05:32:46 +0000 Subject: [PATCH 1/2] update email template --- app/email.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/app/email.py b/app/email.py index e7b0552..ad943b3 100644 --- a/app/email.py +++ b/app/email.py @@ -1,11 +1,10 @@ +from email.mime.text import MIMEText import logging -import yaml import json import os import aiosmtplib from urllib.parse import quote from email.message import EmailMessage -from app.constants import user_directory logger = logging.getLogger('app-logger') @@ -21,8 +20,26 @@ def generate_edit_link(user_config: dict) -> str: return edit_link -def generate_email_content(edit_link: str): - return f"Sent via aiosmtplib! Here's your edit link: {edit_link}" +def generate_email_content(edit_link: str, user_config: dict): + name: str = user_config.get("general", {}).get("name") + if name is None: + name = "WATcloud user" + first_name:str = name.split(" ")[0] + + email_body = ( + f"" + f"" + f"

" + f"Hello {first_name},

" + f"As requested, here is the link to edit your WATcloud user config:
" + f"Edit Link

" + f"Thanks,
" + f"WATcloud Team.
" + f"

" + f"" + ) + # return f"Sent via aiosmtplib! Here's your edit link: {edit_link}" + return email_body async def send_email(user_config: dict, email_address: str) -> None: @@ -31,8 +48,8 @@ async def send_email(user_config: dict, email_address: str) -> None: message = EmailMessage() message["From"] = "onboarding-noreply@watonomous.ca" message["To"] = email_address - message["Subject"] = "Hello World!" - message.set_content(generate_email_content(edit_link)) + message["Subject"] = "WATcloud User Config Edit Link" + message.set_content(generate_email_content(edit_link, user_config), subtype='html') username = os.getenv("EMAIL_ADDRESS") password = os.getenv("EMAIL_PASSWORD") From 895fb6fcc1f24f57e665e11dd81ba83edf032793 Mon Sep 17 00:00:00 2001 From: Jimmy Jiang Date: Sun, 19 Nov 2023 22:00:23 +0000 Subject: [PATCH 2/2] address PR comments --- app/email.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/email.py b/app/email.py index ad943b3..9503b73 100644 --- a/app/email.py +++ b/app/email.py @@ -1,4 +1,3 @@ -from email.mime.text import MIMEText import logging import json import os @@ -30,15 +29,17 @@ def generate_email_content(edit_link: str, user_config: dict): f"" f"" f"

" - f"Hello {first_name},

" - f"As requested, here is the link to edit your WATcloud user config:
" + f"Hello {first_name},

" + f"Greetings from WATcloud! Your WATcloud user config edit link is ready for you:
" f"Edit Link

" - f"Thanks,
" + f"If you have any questions or need assistance, don't hesitate to reach out" + f" to your WATcloud contact or the WATcloud team at" + f" infra-outreach@watonomous.ca.

" + f"Vroom vroom,
" f"WATcloud Team.
" f"

" f"" ) - # return f"Sent via aiosmtplib! Here's your edit link: {edit_link}" return email_body @@ -49,6 +50,7 @@ async def send_email(user_config: dict, email_address: str) -> None: message["From"] = "onboarding-noreply@watonomous.ca" message["To"] = email_address message["Subject"] = "WATcloud User Config Edit Link" + message["Reply-To"] = "infra-outreach@watonomous.ca" message.set_content(generate_email_content(edit_link, user_config), subtype='html') username = os.getenv("EMAIL_ADDRESS")