Email for professionals and teams
support subaddressing (plus and dot signs)
Hieu Nguyen (Jack)767a27d41d02
diff --git a/src/lib/email/recipient-address.ts b/src/lib/email/recipient-address.tsnew file mode 100644index 0000000..c9c6454--- /dev/null+++ b/src/lib/email/recipient-address.ts@@ -0,0 +1,24 @@+import { parseAddress } from "@/lib/utils";+import type { ParsedRecipientAddress } from "./recipient-address-types";++export function normalizeRecipientLocalPart(localPart: string): string {+ const [baseLocalPart] = localPart.split("+", 1);+ return baseLocalPart+ .replaceAll(".", "")+ .toLowerCase();+}++export function parseRecipientAddress(address: string): ParsedRecipientAddress | null {+ const parsed = parseAddress(address);+ if (!parsed) return null;++ const localPart = normalizeRecipientLocalPart(parsed.local);+ if (!localPart) return null;++ return {+ original: address,+ localPart,+ domain: parsed.domain,+ normalizedAddress: `${localPart}@${parsed.domain}`,+ };+}