diff --git a/app/email.py b/app/email.py index e7b0552..9503b73 100644 --- a/app/email.py +++ b/app/email.py @@ -1,11 +1,9 @@ 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 +19,28 @@ 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"Greetings from WATcloud! Your WATcloud user config edit link is ready for you:
" + f"Edit Link

" + 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 email_body async def send_email(user_config: dict, email_address: str) -> None: @@ -31,8 +49,9 @@ 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["Reply-To"] = "infra-outreach@watonomous.ca" + message.set_content(generate_email_content(edit_link, user_config), subtype='html') username = os.getenv("EMAIL_ADDRESS") password = os.getenv("EMAIL_PASSWORD")