* fix: join multiple Reply-To addresses as comma-separated string Some SMTP providers (e.g., SendLayer) reject emails when Reply-To is passed as an array to nodemailer, which serializes it as multiple Reply-To headers. Using a comma-joined string is RFC 2822 compliant and works universally across all SMTP providers. Fixes #28610 * test: add unit tests for getReplyToHeader SMTP compatibility - Verify replyTo is always returned as comma-separated string, not array - Test single email, multiple emails, and empty email cases - Add RFC 5322 compliance test for SMTP compatibility Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: add RFC 5322 reference comment to getReplyToHeader tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Lawrence Christian <67164412+LCNDevs@users.noreply.github.com> Co-authored-by: Romit <85230081+romitg2@users.noreply.github.com> Co-authored-by: Romit <romitgabani1.work@gmail.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
32 lines
753 B
TypeScript
32 lines
753 B
TypeScript
import type { CalendarEvent } from "@calcom/types/Calendar";
|
|
|
|
import { getReplyToEmail } from "./getReplyToEmail";
|
|
|
|
export function getReplyToHeader(
|
|
calEvent: CalendarEvent,
|
|
additionalEmails?: string | string[],
|
|
excludeOrganizerEmail?: boolean
|
|
) {
|
|
const replyToEmail = getReplyToEmail(calEvent, excludeOrganizerEmail ?? calEvent.hideOrganizerEmail);
|
|
const emailArray: string[] = [];
|
|
|
|
if (additionalEmails) {
|
|
if (Array.isArray(additionalEmails)) {
|
|
emailArray.push(...additionalEmails);
|
|
} else {
|
|
emailArray.push(additionalEmails);
|
|
}
|
|
}
|
|
|
|
if (replyToEmail) {
|
|
emailArray.push(replyToEmail);
|
|
}
|
|
|
|
if (emailArray.length === 0) {
|
|
return {};
|
|
}
|
|
|
|
const replyTo = emailArray.join(", ");
|
|
return { replyTo };
|
|
}
|