diff --git a/packages/emails/templates/attendee-add-guests-email.ts b/packages/emails/templates/attendee-add-guests-email.ts index cb1b9dddf2..b2ef5dd2c6 100644 --- a/packages/emails/templates/attendee-add-guests-email.ts +++ b/packages/emails/templates/attendee-add-guests-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { renderEmail } from "../"; import generateIcsFile, { GenerateIcsRole } from "../lib/generateIcsFile"; @@ -14,7 +14,7 @@ export default class AttendeeAddGuestsEmail extends AttendeeScheduledEmail { }), to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: getReplyToEmail(this.calEvent), + ...getReplyToHeader(this.calEvent), subject: `${this.t("guests_added_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, diff --git a/packages/emails/templates/attendee-awaiting-payment-email.ts b/packages/emails/templates/attendee-awaiting-payment-email.ts index 2470530d40..31888e59e2 100644 --- a/packages/emails/templates/attendee-awaiting-payment-email.ts +++ b/packages/emails/templates/attendee-awaiting-payment-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { renderEmail } from "../"; import AttendeeScheduledEmail from "./attendee-scheduled-email"; @@ -8,7 +8,7 @@ export default class AttendeeAwaitingPaymentEmail extends AttendeeScheduledEmail return { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: getReplyToEmail(this.calEvent), + ...getReplyToHeader(this.calEvent), subject: `${this.attendee.language.translate("complete_your_booking_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/attendee-cancelled-email.ts b/packages/emails/templates/attendee-cancelled-email.ts index 42bcaed2b2..7992eb4dc4 100644 --- a/packages/emails/templates/attendee-cancelled-email.ts +++ b/packages/emails/templates/attendee-cancelled-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { renderEmail } from "../"; @@ -15,7 +15,7 @@ export default class AttendeeCancelledEmail extends AttendeeScheduledEmail { }), to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: getReplyToEmail(this.calEvent), + ...getReplyToHeader(this.calEvent), subject: `${this.t("event_cancelled_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/attendee-cancelled-seat-email.ts b/packages/emails/templates/attendee-cancelled-seat-email.ts index 6d0984f637..590ce65d6e 100644 --- a/packages/emails/templates/attendee-cancelled-seat-email.ts +++ b/packages/emails/templates/attendee-cancelled-seat-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { renderEmail } from "../"; import AttendeeScheduledEmail from "./attendee-scheduled-email"; @@ -8,7 +8,7 @@ export default class AttendeeCancelledSeatEmail extends AttendeeScheduledEmail { return { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: getReplyToEmail(this.calEvent), + ...getReplyToHeader(this.calEvent), subject: `${this.t("event_no_longer_attending_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/attendee-daily-video-download-recording-email.ts b/packages/emails/templates/attendee-daily-video-download-recording-email.ts index af76e449ac..7b54067333 100644 --- a/packages/emails/templates/attendee-daily-video-download-recording-email.ts +++ b/packages/emails/templates/attendee-daily-video-download-recording-email.ts @@ -1,7 +1,7 @@ // TODO: We should find a way to keep App specific email templates within the App itself import type { TFunction } from "i18next"; -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { TimeFormat } from "@calcom/lib/timeFormat"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; @@ -26,12 +26,10 @@ export default class AttendeeDailyVideoDownloadRecordingEmail extends BaseEmail return { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: [ - ...this.calEvent.attendees - .filter(({ email }) => email !== this.attendee.email) - .map(({ email }) => email), - getReplyToEmail(this.calEvent), - ], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.filter(({ email }) => email !== this.attendee.email).map(({ email }) => email) + ), subject: `${this.t("download_recording_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/attendee-daily-video-download-transcript-email.ts b/packages/emails/templates/attendee-daily-video-download-transcript-email.ts index e2ffed8c43..b9033c099c 100644 --- a/packages/emails/templates/attendee-daily-video-download-transcript-email.ts +++ b/packages/emails/templates/attendee-daily-video-download-transcript-email.ts @@ -1,6 +1,6 @@ import type { TFunction } from "i18next"; -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { TimeFormat } from "@calcom/lib/timeFormat"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; @@ -37,12 +37,10 @@ export default class AttendeeDailyVideoDownloadTranscriptEmail extends BaseEmail return { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: [ - ...this.calEvent.attendees - .filter(({ email }) => email !== this.attendee.email) - .map(({ email }) => email), - getReplyToEmail(this.calEvent), - ], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.filter(({ email }) => email !== this.attendee.email).map(({ email }) => email) + ), subject: `${this.t("download_transcript_email_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/attendee-declined-email.ts b/packages/emails/templates/attendee-declined-email.ts index 53a9e7e3de..37dd9b2806 100644 --- a/packages/emails/templates/attendee-declined-email.ts +++ b/packages/emails/templates/attendee-declined-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { renderEmail } from "../"; @@ -9,7 +9,7 @@ export default class AttendeeDeclinedEmail extends AttendeeScheduledEmail { return { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: getReplyToEmail(this.calEvent), + ...getReplyToHeader(this.calEvent), subject: `${this.t("event_declined_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/attendee-location-change-email.ts b/packages/emails/templates/attendee-location-change-email.ts index fb6fa70739..5e20668a85 100644 --- a/packages/emails/templates/attendee-location-change-email.ts +++ b/packages/emails/templates/attendee-location-change-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { renderEmail } from "../"; import generateIcsFile, { GenerateIcsRole } from "../lib/generateIcsFile"; @@ -14,7 +14,7 @@ export default class AttendeeLocationChangeEmail extends AttendeeScheduledEmail }), to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: getReplyToEmail(this.calEvent), + ...getReplyToHeader(this.calEvent), subject: `${this.t("location_changed_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.team?.name || this.calEvent.organizer.name, diff --git a/packages/emails/templates/attendee-request-email.ts b/packages/emails/templates/attendee-request-email.ts index ba7781a4e1..6bef955e58 100644 --- a/packages/emails/templates/attendee-request-email.ts +++ b/packages/emails/templates/attendee-request-email.ts @@ -1,5 +1,5 @@ import { EMAIL_FROM_NAME } from "@calcom/lib/constants"; -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { renderEmail } from "../"; @@ -8,16 +8,13 @@ import AttendeeScheduledEmail from "./attendee-scheduled-email"; export default class AttendeeRequestEmail extends AttendeeScheduledEmail { protected async getNodeMailerPayload(): Promise> { const toAddresses = this.calEvent.attendees.map((attendee) => attendee.email); - return { from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, to: toAddresses.join(","), - replyTo: [ - ...this.calEvent.attendees - .filter(({ email }) => email !== this.attendee.email) - .map(({ email }) => email), - getReplyToEmail(this.calEvent), - ], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.filter(({ email }) => email !== this.attendee.email).map(({ email }) => email) + ), subject: `${this.calEvent.attendees[0].language.translate("booking_submitted_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/attendee-rescheduled-email.ts b/packages/emails/templates/attendee-rescheduled-email.ts index 43f16a4a17..a8860de163 100644 --- a/packages/emails/templates/attendee-rescheduled-email.ts +++ b/packages/emails/templates/attendee-rescheduled-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { renderEmail } from "../"; @@ -15,12 +15,10 @@ export default class AttendeeRescheduledEmail extends AttendeeScheduledEmail { }), to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: [ - ...this.calEvent.attendees - .filter(({ email }) => email !== this.attendee.email) - .map(({ email }) => email), - getReplyToEmail(this.calEvent), - ], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.filter(({ email }) => email !== this.attendee.email).map(({ email }) => email) + ), subject: `${this.attendee.language.translate("event_type_has_been_rescheduled_on_time_date", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/attendee-scheduled-email.ts b/packages/emails/templates/attendee-scheduled-email.ts index 67cdbae14f..0bdec1c747 100644 --- a/packages/emails/templates/attendee-scheduled-email.ts +++ b/packages/emails/templates/attendee-scheduled-email.ts @@ -2,7 +2,7 @@ import type { TFunction } from "i18next"; import { default as cloneDeep } from "lodash/cloneDeep"; import { getRichDescription } from "@calcom/lib/CalEventParser"; -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { TimeFormat } from "@calcom/lib/timeFormat"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; @@ -40,12 +40,10 @@ export default class AttendeeScheduledEmail extends BaseEmail { }), to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: [ - ...this.calEvent.attendees - .filter(({ email }) => email !== this.attendee.email) - .map(({ email }) => email), - getReplyToEmail(this.calEvent), - ], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.filter(({ email }) => email !== this.attendee.email).map(({ email }) => email) + ), subject: `${this.calEvent.title}`, html: await this.getHtml(clonedCalEvent, this.attendee), text: this.getTextBody(), diff --git a/packages/emails/templates/attendee-updated-email.ts b/packages/emails/templates/attendee-updated-email.ts index 6e5133b5af..55458c4be2 100644 --- a/packages/emails/templates/attendee-updated-email.ts +++ b/packages/emails/templates/attendee-updated-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { renderEmail } from "../"; @@ -15,12 +15,10 @@ export default class AttendeeUpdatedEmail extends AttendeeScheduledEmail { }), to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: [ - ...this.calEvent.attendees - .filter(({ email }) => email !== this.attendee.email) - .map(({ email }) => email), - getReplyToEmail(this.calEvent), - ], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.filter(({ email }) => email !== this.attendee.email).map(({ email }) => email) + ), subject: `${this.attendee.language.translate("event_type_has_been_updated", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/no-show-fee-charged-email.ts b/packages/emails/templates/no-show-fee-charged-email.ts index f75c5eade9..9e2e42f56e 100644 --- a/packages/emails/templates/no-show-fee-charged-email.ts +++ b/packages/emails/templates/no-show-fee-charged-email.ts @@ -1,4 +1,4 @@ -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { renderEmail } from "../"; import AttendeeScheduledEmail from "./attendee-scheduled-email"; @@ -9,7 +9,7 @@ export default class NoShowFeeChargedEmail extends AttendeeScheduledEmail { return { to: `${this.attendee.name} <${this.attendee.email}>`, from: `${this.calEvent.organizer.name} <${this.getMailerOptions().from}>`, - replyTo: getReplyToEmail(this.calEvent), + ...getReplyToHeader(this.calEvent), subject: `${this.attendee.language.translate("no_show_fee_charged_email_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/organizer-add-guests-email.ts b/packages/emails/templates/organizer-add-guests-email.ts index d88008b49c..6aac64614c 100644 --- a/packages/emails/templates/organizer-add-guests-email.ts +++ b/packages/emails/templates/organizer-add-guests-email.ts @@ -1,4 +1,5 @@ import { APP_NAME } from "@calcom/lib/constants"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { renderEmail } from "../"; import generateIcsFile, { GenerateIcsRole } from "../lib/generateIcsFile"; @@ -16,7 +17,10 @@ export default class OrganizerAddGuestsEmail extends OrganizerScheduledEmail { }), from: `${APP_NAME} <${this.getMailerOptions().from}>`, to: toAddresses.join(","), - replyTo: [...this.calEvent.attendees.map(({ email }) => email)], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.map(({ email }) => email) + ), subject: `${this.t("guests_added_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.attendees[0].name, diff --git a/packages/emails/templates/organizer-daily-video-download-recording-email.ts b/packages/emails/templates/organizer-daily-video-download-recording-email.ts index 28a25f6a69..9472b31ffa 100644 --- a/packages/emails/templates/organizer-daily-video-download-recording-email.ts +++ b/packages/emails/templates/organizer-daily-video-download-recording-email.ts @@ -1,6 +1,7 @@ import type { TFunction } from "i18next"; import { EMAIL_FROM_NAME } from "@calcom/lib/constants"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { TimeFormat } from "@calcom/lib/timeFormat"; import type { CalendarEvent } from "@calcom/types/Calendar"; @@ -23,7 +24,10 @@ export default class OrganizerDailyVideoDownloadRecordingEmail extends BaseEmail return { to: `${this.calEvent.organizer.email}>`, from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, - replyTo: [...this.calEvent.attendees.map(({ email }) => email)], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.map(({ email }) => email) + ), subject: `${this.t("download_recording_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/organizer-daily-video-download-transcript-email.ts b/packages/emails/templates/organizer-daily-video-download-transcript-email.ts index f1320a73e9..854ca60de2 100644 --- a/packages/emails/templates/organizer-daily-video-download-transcript-email.ts +++ b/packages/emails/templates/organizer-daily-video-download-transcript-email.ts @@ -1,6 +1,7 @@ import type { TFunction } from "i18next"; import { EMAIL_FROM_NAME } from "@calcom/lib/constants"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { TimeFormat } from "@calcom/lib/timeFormat"; import type { CalendarEvent } from "@calcom/types/Calendar"; @@ -35,7 +36,10 @@ export default class OrganizerDailyVideoDownloadTranscriptEmail extends BaseEmai return { to: `${this.calEvent.organizer.email}>`, from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, - replyTo: [...this.calEvent.attendees.map(({ email }) => email)], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.map(({ email }) => email) + ), subject: `${this.t("download_transcript_email_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/organizer-location-change-email.ts b/packages/emails/templates/organizer-location-change-email.ts index b0c4261901..fe6ccf1521 100644 --- a/packages/emails/templates/organizer-location-change-email.ts +++ b/packages/emails/templates/organizer-location-change-email.ts @@ -1,4 +1,5 @@ import { EMAIL_FROM_NAME } from "@calcom/lib/constants"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { renderEmail } from "../"; import generateIcsFile, { GenerateIcsRole } from "../lib/generateIcsFile"; @@ -16,7 +17,10 @@ export default class OrganizerLocationChangeEmail extends OrganizerScheduledEmai }), from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, to: toAddresses.join(","), - replyTo: [...this.calEvent.attendees.map(({ email }) => email)], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.map(({ email }) => email) + ), subject: `${this.t("location_changed_event_type_subject", { eventType: this.calEvent.type, name: this.calEvent.attendees[0].name, diff --git a/packages/emails/templates/organizer-request-email.ts b/packages/emails/templates/organizer-request-email.ts index f21de000d0..8d20987b37 100644 --- a/packages/emails/templates/organizer-request-email.ts +++ b/packages/emails/templates/organizer-request-email.ts @@ -1,5 +1,6 @@ import { checkIfUserHasFeatureController } from "@calcom/features/flags/operations/check-if-user-has-feature.controller"; import { EMAIL_FROM_NAME } from "@calcom/lib/constants"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { renderEmail } from "../"; @@ -21,7 +22,10 @@ export default class OrganizerRequestEmail extends OrganizerScheduledEmail { return { from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, to: toAddresses.join(","), - replyTo: [...this.calEvent.attendees.map(({ email }) => email)], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.map(({ email }) => email) + ), subject: `${this.t("awaiting_approval")}: ${this.calEvent.title}`, html: await this.getHtmlRequestEmail(template, this.calEvent, this.calEvent.organizer), text: this.getTextBody("event_awaiting_approval"), diff --git a/packages/emails/templates/organizer-request-reminder-email.ts b/packages/emails/templates/organizer-request-reminder-email.ts index fd08080a3a..c7b6392441 100644 --- a/packages/emails/templates/organizer-request-reminder-email.ts +++ b/packages/emails/templates/organizer-request-reminder-email.ts @@ -1,4 +1,5 @@ import { EMAIL_FROM_NAME } from "@calcom/lib/constants"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { renderEmail } from "../"; import OrganizerRequestEmail from "./organizer-request-email"; @@ -10,7 +11,10 @@ export default class OrganizerRequestReminderEmail extends OrganizerRequestEmail return { from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, to: toAddresses.join(","), - replyTo: [...this.calEvent.attendees.map(({ email }) => email)], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.map(({ email }) => email) + ), subject: `${this.t("event_awaiting_approval_subject", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/organizer-rescheduled-email.ts b/packages/emails/templates/organizer-rescheduled-email.ts index 9b96031123..e6cff8828b 100644 --- a/packages/emails/templates/organizer-rescheduled-email.ts +++ b/packages/emails/templates/organizer-rescheduled-email.ts @@ -1,5 +1,5 @@ import { EMAIL_FROM_NAME } from "@calcom/lib/constants"; -import { getReplyToEmail } from "@calcom/lib/getReplyToEmail"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { renderEmail } from "../"; @@ -9,7 +9,6 @@ import OrganizerScheduledEmail from "./organizer-scheduled-email"; export default class OrganizerRescheduledEmail extends OrganizerScheduledEmail { protected async getNodeMailerPayload(): Promise> { const toAddresses = [this.teamMember?.email || this.calEvent.organizer.email]; - return { icalEvent: generateIcsFile({ calEvent: this.calEvent, @@ -18,7 +17,10 @@ export default class OrganizerRescheduledEmail extends OrganizerScheduledEmail { }), from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, to: toAddresses.join(","), - replyTo: [...this.calEvent.attendees.map(({ email }) => email), getReplyToEmail(this.calEvent)], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.map(({ email }) => email) + ), subject: `${this.calEvent.organizer.language.translate("event_type_has_been_rescheduled_on_time_date", { title: this.calEvent.title, date: this.getFormattedDate(), diff --git a/packages/emails/templates/organizer-scheduled-email.ts b/packages/emails/templates/organizer-scheduled-email.ts index 29b70741e2..c346597de7 100644 --- a/packages/emails/templates/organizer-scheduled-email.ts +++ b/packages/emails/templates/organizer-scheduled-email.ts @@ -3,6 +3,7 @@ import { default as cloneDeep } from "lodash/cloneDeep"; import { getRichDescription } from "@calcom/lib/CalEventParser"; import { EMAIL_FROM_NAME } from "@calcom/lib/constants"; +import { getReplyToHeader } from "@calcom/lib/getReplyToHeader"; import { TimeFormat } from "@calcom/lib/timeFormat"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; @@ -49,7 +50,10 @@ export default class OrganizerScheduledEmail extends BaseEmail { }), from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`, to: toAddresses.join(","), - replyTo: [...this.calEvent.attendees.map(({ email }) => email)], + ...getReplyToHeader( + this.calEvent, + this.calEvent.attendees.map(({ email }) => email) + ), subject: `${this.newSeat ? `${this.t("new_attendee")}: ` : ""}${this.calEvent.title}`, html: await this.getHtml( clonedCalEvent, diff --git a/packages/emails/templates/workflow-email.ts b/packages/emails/templates/workflow-email.ts index 0520f79793..51aa1a9c4a 100644 --- a/packages/emails/templates/workflow-email.ts +++ b/packages/emails/templates/workflow-email.ts @@ -14,7 +14,7 @@ export type WorkflowEmailData = { to: string; subject: string; html: string; - replyTo: string; + replyTo?: string; sender?: string | null; attachments?: Attachment[]; }; @@ -31,7 +31,7 @@ export default class WorkflowEmail extends BaseEmail { return { to: this.mailData.to, from: `${this.mailData.sender || SENDER_NAME} <${this.getMailerOptions().from}>`, - replyTo: this.mailData.replyTo, + ...(this.mailData.replyTo && { replyTo: this.mailData.replyTo }), subject: this.mailData.subject, html: addHTMLStyles(this.mailData.html), attachments: this.mailData.attachments, diff --git a/packages/features/ee/workflows/api/scheduleEmailReminders.ts b/packages/features/ee/workflows/api/scheduleEmailReminders.ts index 16b38241a0..72bf5b8e4d 100644 --- a/packages/features/ee/workflows/api/scheduleEmailReminders.ts +++ b/packages/features/ee/workflows/api/scheduleEmailReminders.ts @@ -332,10 +332,12 @@ export async function handler(req: NextRequest) { html: emailContent.emailBody, batchId: batchId, sendAt: dayjs(reminder.scheduledDate).unix(), - replyTo: - reminder.booking?.eventType?.customReplyToEmail ?? - reminder.booking?.userPrimaryEmail ?? - reminder.booking.user?.email, + ...(!reminder.booking?.eventType?.hideOrganizerEmail && { + replyTo: + reminder.booking?.eventType?.customReplyToEmail ?? + reminder.booking?.userPrimaryEmail ?? + reminder.booking.user?.email, + }), attachments: reminder.workflowStep.includeCalendarEvent ? [ { @@ -410,10 +412,12 @@ export async function handler(req: NextRequest) { html: emailContent.emailBody, batchId: batchId, sendAt: dayjs(reminder.scheduledDate).unix(), - replyTo: - reminder.booking?.eventType?.customReplyToEmail || - reminder.booking?.userPrimaryEmail || - reminder.booking.user?.email, + ...(!reminder.booking?.eventType?.hideOrganizerEmail && { + replyTo: + reminder.booking?.eventType?.customReplyToEmail || + reminder.booking?.userPrimaryEmail || + reminder.booking.user?.email, + }), sender: reminder.workflowStep?.sender, }) ); diff --git a/packages/features/ee/workflows/lib/reminders/emailReminderManager.ts b/packages/features/ee/workflows/lib/reminders/emailReminderManager.ts index 3ee9609b7b..9062d4f6c0 100644 --- a/packages/features/ee/workflows/lib/reminders/emailReminderManager.ts +++ b/packages/features/ee/workflows/lib/reminders/emailReminderManager.ts @@ -251,7 +251,7 @@ export const scheduleEmailReminder = async (args: scheduleEmailReminderArgs) => return { subject: emailContent.emailSubject, html: emailContent.emailBody, - replyTo: evt?.eventType?.customReplyToEmail || evt.organizer.email, + ...(!evt.hideOrganizerEmail && { replyTo: evt?.eventType?.customReplyToEmail || evt.organizer.email }), attachments, sender, }; diff --git a/packages/features/tasker/tasks/sendWorkflowEmails.ts b/packages/features/tasker/tasks/sendWorkflowEmails.ts index e0c9bf55b7..62cbf93427 100644 --- a/packages/features/tasker/tasks/sendWorkflowEmails.ts +++ b/packages/features/tasker/tasks/sendWorkflowEmails.ts @@ -6,7 +6,7 @@ export const ZSendWorkflowEmailsSchema = z.object({ to: z.array(z.string()), subject: z.string(), html: z.string(), - replyTo: z.string(), + replyTo: z.string().optional(), sender: z.string().nullable().optional(), attachments: z .array( diff --git a/packages/lib/getReplyToHeader.ts b/packages/lib/getReplyToHeader.ts new file mode 100644 index 0000000000..c32073844b --- /dev/null +++ b/packages/lib/getReplyToHeader.ts @@ -0,0 +1,16 @@ +import type { CalendarEvent } from "@calcom/types/Calendar"; + +import { getReplyToEmail } from "./getReplyToEmail"; + +export function getReplyToHeader(calEvent: CalendarEvent, additionalEmails?: string | string[]) { + if (calEvent.hideOrganizerEmail) return {}; + + const replyToEmail = getReplyToEmail(calEvent); + const replyTo = additionalEmails + ? Array.isArray(additionalEmails) + ? [...additionalEmails, replyToEmail] + : [additionalEmails, replyToEmail] + : replyToEmail; + + return { replyTo }; +}