"""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,
manager_email: str,
company_domain: str,
login_url: str,
initial_password: str,
force_password_change: bool,
) -> tuple[str, str, str]:
first_name = member_first_name.strip() or "there"
organization = company_domain.strip()
manager = manager_name.strip() or "Your administrator"
manager_address = manager_email.strip()
security_note = (
"For your security, you will be asked to create a new password "
"immediately after your first sign-in."
if force_password_change
else (
"We recommend updating your password after your first sign-in "
"from your account settings."
)
)
subject = (
f"Account invitation: {manager} added you to {organization} on {BRAND_NAME}"
)
unexpected_contact = (
f"If you were not expecting this invitation, please contact "
f"{manager} at {manager_address}."
if manager_address
else "If you were not expecting this invitation, please contact your administrator."
)
body_text = (
f"Hello {first_name},\n\n"
f"{manager} has created a work email account for you on {BRAND_NAME}, "
f"the email platform used by {organization}.\n\n"
f"This automated notification was sent to the personal email address "
f"your administrator provided. It contains the sign-in details for "
f"your new organization account.\n\n"
f"Organization: {organization}\n"
f"Work email address: {member_email}\n"
f"Sign-in page: {login_url}\n\n"
f"Sign-in credentials\n"
f" Email: {member_email}\n"
f" Initial password: {initial_password}\n\n"
f"{security_note}\n\n"
f"{unexpected_contact}\n\n"
f"—\n"
f"{BRAND_NAME}\n"
f"{login_url.rsplit('/login', 1)[0] or login_url}\n"
f"This is an account notification sent on behalf of {organization}."
)
preheader = (
f"{manager} added you to {organization}. "
f"Your work email account is ready — review your sign-in details."
)
safe_first = _escape(first_name)
safe_manager = _escape(manager)
safe_org = _escape(organization)
safe_email = _escape(member_email)
safe_password = _escape(initial_password)
safe_login = _escape(login_url)
safe_manager_email = _escape(manager_address)
safe_preheader = _escape(preheader)
safe_security = _escape(security_note)
safe_unexpected = _escape(unexpected_contact)
body_html = f"""
{_escape(subject)}
{safe_preheader}
|
|
|
Organization invitation
You have been added to
{safe_org}
|
|
Hello {safe_first},
{safe_manager} has created a work email
account for you on {BRAND_NAME},
the email platform used by {safe_org}
for business communication.
This message was sent to the personal email address your administrator
provided. Use the details below to access your new organization inbox.
|
Account details
| Organization |
{safe_org} |
| Work email |
{safe_email} |
| Initial password |
{safe_password} |
|
{safe_security}
{safe_unexpected}
|
|
{BRAND_NAME} · {BRAND_HANDLE}
This is an automated account notification sent on behalf of {safe_org}.
{" Reply to " + safe_manager_email + " if you need help." if manager_address else ""}
|
|
|
"""
return subject, body_text, body_html