fix: @ symbol in the from field with friendly name (#174)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: KM Koushik <koushikmohan1996@gmail.com>
This commit is contained in:
Mohannad Faihan Otaibi
2025-06-10 23:26:01 +03:00
committed by GitHub
parent 3212613273
commit 142084af8e

View File

@@ -9,7 +9,10 @@ import { UnsendApiError } from "../public-api/api-error";
const dnsResolveTxt = util.promisify(dns.resolveTxt);
export async function validateDomainFromEmail(email: string, teamId: number) {
let fromDomain = email.split("@")[1];
// Extract email from format like 'Name <email@domain>' this will allow entries such as "Someone @ something <some@domain.com>" to parse correctly as well.
const match = email.match(/<([^>]+)>/);
let fromDomain = match ? match[1].split("@")[1] : email.split("@")[1];
if (fromDomain?.endsWith(">")) {
fromDomain = fromDomain.slice(0, -1);
}