add user email template

This commit is contained in:
debu-2 2026-10-05 19:35:26 +05:30
parent dd0ceef665
commit ebbb582e99
2 changed files with 25 additions and 31 deletions

View file

@ -38,8 +38,13 @@ def build_employee_invitation_email(
)
)
subject = (
f"Account invitation: {manager} added you to {organization} on {BRAND_NAME}"
subject = f"{manager} invited you to join {organization}"
why_received = (
f"You are receiving this because {manager} invited you to a work email "
f"account at {organization} on {BRAND_NAME}. It was sent to the personal "
f"email address your administrator provided so you can complete your "
f"first sign-in."
)
unexpected_contact = (
@ -51,11 +56,7 @@ def build_employee_invitation_email(
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"{why_received}\n\n"
f"Organization: {organization}\n"
f"Work email address: {member_email}\n"
f"Sign-in page: {login_url}\n\n"
@ -67,12 +68,13 @@ def build_employee_invitation_email(
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}."
f"This is a one-time account notification from {BRAND_NAME} on behalf of "
f"{organization}. You cannot unsubscribe from required account emails."
)
preheader = (
f"{manager} added you to {organization}. "
f"Your work email account is ready — review your sign-in details."
f"{manager} invited you to join {organization}. "
f"Use the sign-in details below to access your work inbox."
)
safe_first = _escape(first_name)
@ -85,6 +87,7 @@ def build_employee_invitation_email(
safe_preheader = _escape(preheader)
safe_security = _escape(security_note)
safe_unexpected = _escape(unexpected_contact)
safe_why_received = _escape(why_received)
body_html = f"""<!DOCTYPE html>
<html lang="en">
@ -130,9 +133,9 @@ def build_employee_invitation_email(
<td style="padding:28px 32px 18px;background:linear-gradient(135deg,#fffdfb 0%,#fff6f2 100%);
border-bottom:1px solid #f3ece7;">
<p style="margin:0 0 10px;font-size:12px;font-weight:700;letter-spacing:1px;
text-transform:uppercase;color:#ff6a52;">Organization invitation</p>
text-transform:uppercase;color:#ff6a52;">Work email invitation</p>
<h1 style="margin:0;font-size:26px;line-height:1.25;font-weight:700;color:#080821;">
You have been added to<br />
{safe_manager} invited you to join<br />
<span style="color:#ff6a52;">{safe_org}</span>
</h1>
</td>
@ -142,15 +145,8 @@ def build_employee_invitation_email(
<p style="margin:0 0 16px;font-size:16px;line-height:1.65;color:#080821;">
Hello {safe_first},
</p>
<p style="margin:0 0 16px;font-size:15px;line-height:1.7;color:#67677a;">
<strong style="color:#080821;">{safe_manager}</strong> has created a work email
account for you on <strong style="color:#080821;">{BRAND_NAME}</strong>,
the email platform used by <strong style="color:#080821;">{safe_org}</strong>
for business communication.
</p>
<p style="margin:0 0 24px;font-size:15px;line-height:1.7;color:#67677a;">
This message was sent to the personal email address your administrator
provided. Use the details below to access your new organization inbox.
{safe_why_received}
</p>
<table role="presentation" width="100%" cellspacing="0" cellpadding="0"
style="margin:0 0 24px;background-color:#fff3ef;border:1px solid #ffe1d8;border-radius:14px;">
@ -201,8 +197,8 @@ def build_employee_invitation_email(
{BRAND_NAME} · {BRAND_HANDLE}
</p>
<p style="margin:0;font-size:12px;line-height:1.6;color:#a8a4ae;">
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 ""}
One-time account notification from {BRAND_NAME} on behalf of {safe_org}.
{" Questions? Reply to " + safe_manager_email + "." if manager_address else ""}
</p>
</td>
</tr>

View file

@ -13,20 +13,18 @@ def test_employee_invitation_uses_gentic_branding():
force_password_change=True,
)
assert "aGentic Email" in subject
assert subject == (
"Account invitation: Suyash Dixit added you to road.rentals on aGentic Email"
)
assert subject == "Suyash Dixit invited you to join road.rentals"
assert "AGMail" not in subject
assert "Suyash Dixit" in subject
assert "road.rentals" in subject
assert "aGentic Email" not in subject
assert "Gentic Email" in body_text
assert "aGentic Email" in body_text
assert "AGMail" not in body_text
assert "Suyash Dixit has created a work email account" in body_text
assert "You are receiving this because Suyash Dixit invited you" in body_text
assert "cannot unsubscribe from required account emails" in body_text
assert "anurag@road.rentals" in body_text
assert "gentic.email" in body_html
assert "Organization invitation" in body_html
assert "Work email invitation" in body_html
assert "invited you to join" in body_html
assert "Sign in to aGentic Email" in body_html
assert "AGMail" not in body_html