"""HTML and plain-text templates for transactional email."""
from __future__ import annotations
import html
BRAND_NAME = "aGentic Email"
BRAND_HANDLE = "@gentic.email"
def _escape(value: str) -> str:
return html.escape(value, quote=True)
def build_employee_invitation_email(
*,
member_first_name: str,
member_email: str,
manager_name: str,
company_domain: str,
invite_url: str,
expires_hours: int = 48,
) -> tuple[str, str, str]:
first_name = member_first_name.strip() or "there"
organization = company_domain.strip()
manager = manager_name.strip() or "Your administrator"
subject = f"{manager} invited you to join {organization}"
body_text = (
f"Hello {first_name},\n\n"
f"{manager} invited you to join {organization}.\n\n"
f"Your work email:\n"
f"{member_email}\n\n"
f"Set up your account:\n"
f"{invite_url}\n\n"
f"This invitation expires in {expires_hours} hours.\n\n"
f"If you weren't expecting this invitation,\n"
f"you can safely ignore this email.\n\n"
f"—\n"
f"{BRAND_NAME}\n"
f"This invitation was sent because {manager} created an account "
f"for you at {organization}."
)
preheader = (
f"{manager} invited you to join {organization}. "
f"Set up your work email account."
)
safe_first = _escape(first_name)
safe_manager = _escape(manager)
safe_org = _escape(organization)
safe_email = _escape(member_email)
safe_invite = _escape(invite_url)
safe_preheader = _escape(preheader)
body_html = f"""
{_escape(subject)}
{safe_preheader}
|
|
|
Work email invitation
{safe_manager} invited you to join
{safe_org}
|
|
Hello {safe_first},
|
Your work email
{safe_email}
|
This invitation expires in {expires_hours} hours.
If you weren't expecting this invitation,
you can safely ignore this email.
|
|
This invitation was sent because {safe_manager} created an account
for you at {safe_org}.
|
|
|
"""
return subject, body_text, body_html