Skip to content

Commit

Permalink
feat: adds env variable for email sender name (#15598)
Browse files Browse the repository at this point in the history
* feat: adds env variable for email sender name

* update env declaration file

---------

Co-authored-by: unknown <adhabal2002@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
  • Loading branch information
3 people authored Jun 27, 2024
1 parent dfbcf47 commit 3e10e2d
Show file tree
Hide file tree
Showing 33 changed files with 62 additions and 58 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ API_KEY_PREFIX=cal_
# allow access to the nodemailer transports from the .env file. E-mail templates are accessible within lib/emails/
# Configures the global From: header whilst sending emails.
EMAIL_FROM='notifications@yourselfhostedcal.com'
EMAIL_FROM_NAME='Cal.com'

# Configure SMTP settings (@see https://nodemailer.com/smtp/).
# Configuration to receive emails locally (mailhog)
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/account-verify-email.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME, COMPANY_NAME } from "@calcom/lib/constants";
import { APP_NAME, COMPANY_NAME, EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import BaseEmail from "./_base-email";
Expand Down Expand Up @@ -30,7 +30,7 @@ export default class AccountVerifyEmail extends BaseEmail {
: "verify_email_subject";
return {
to: `${this.verifyAccountInput.user.name} <${this.verifyAccountInput.user.email}>`,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
subject: this.verifyAccountInput.language(emailSubjectKey, {
appName: APP_NAME,
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/admin-organization-notification.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import BaseEmail from "./_base-email";
Expand All @@ -24,7 +24,7 @@ export default class AdminOrganizationNotification extends BaseEmail {

protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: this.input.instanceAdmins.map((admin) => admin.email).join(","),
subject: `${this.input.t("admin_org_notification_email_subject")}`,
html: await renderEmail("AdminOrganizationNotificationEmail", {
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/attendee-request-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import AttendeeScheduledEmail from "./attendee-scheduled-email";
Expand All @@ -8,7 +8,7 @@ export default class AttendeeRequestEmail extends AttendeeScheduledEmail {
const toAddresses = this.calEvent.attendees.map((attendee) => attendee.email);

return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
replyTo: [...this.calEvent.attendees.map(({ email }) => email), this.calEvent.organizer.email],
subject: `${this.calEvent.attendees[0].language.translate("booking_submitted_subject", {
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/attendee-verify-email.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME, COMPANY_NAME } from "@calcom/lib/constants";
import { APP_NAME, COMPANY_NAME, EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import BaseEmail from "./_base-email";
Expand All @@ -27,7 +27,7 @@ export default class AttendeeVerifyEmail extends BaseEmail {
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: `${this.verifyAccountInput.user.name} <${this.verifyAccountInput.user.email}>`,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
subject: this.verifyAccountInput.language(
`verify_email_subject${this.verifyAccountInput.isVerifyingEmail ? "_verifying_email" : ""}`,
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getManageLink } from "@calcom/lib/CalEventParser";
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";
import type { CalendarEvent } from "@calcom/types/Calendar";

import { renderEmail } from "..";
Expand Down Expand Up @@ -30,7 +30,7 @@ export default class AttendeeWasRequestedToRescheduleEmail extends OrganizerSche
}),
method: "REQUEST",
},
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
subject: `${this.t("requested_to_reschedule_subject_attendee", {
eventType: this.calEvent.type,
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/booking-redirect-notification.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "..";
import BaseEmail from "./_base-email";
Expand All @@ -25,7 +25,7 @@ export default class BookingRedirectNotification extends BaseEmail {
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: `${this.bookingRedirect.toName} <${this.bookingRedirect.toEmail}>`,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
subject: this.bookingRedirect.language("booking_redirect_email_subject"),
html: await renderEmail("BookingRedirectEmailNotification", {
...this.bookingRedirect,
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/broken-integration-email.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TFunction } from "next-i18next";

import { getRichDescription } from "@calcom/lib/CalEventParser";
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";
import { TimeFormat } from "@calcom/lib/timeFormat";
import type { CalendarEvent } from "@calcom/types/Calendar";

Expand All @@ -25,7 +25,7 @@ export default class BrokenIntegrationEmail extends BaseEmail {
const toAddresses = [this.calEvent.organizer.email];

return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
subject: `[Action Required] ${this.t("confirmed_event_type_subject", {
eventType: this.calEvent.type,
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/change-account-email-verify.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME, COMPANY_NAME } from "@calcom/lib/constants";
import { APP_NAME, COMPANY_NAME, EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import BaseEmail from "./_base-email";
Expand All @@ -27,7 +27,7 @@ export default class ChangeOfEmailVerifyEmail extends BaseEmail {
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: `${this.changeEvent.user.name} <${this.changeEvent.user.emailTo}>`,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
subject: this.changeEvent.language("change_of_email", {
appName: APP_NAME,
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/disabled-app-email.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "..";
import BaseEmail from "./_base-email";
Expand Down Expand Up @@ -32,7 +32,7 @@ export default class DisabledAppEmail extends BaseEmail {

protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: this.email,
subject:
this.title && this.eventTypeId
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/feedback-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import BaseEmail from "./_base-email";
Expand All @@ -20,7 +20,7 @@ export default class FeedbackEmail extends BaseEmail {

protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: process.env.SEND_FEEDBACK_EMAIL,
subject: `User Feedback`,
html: await renderEmail("FeedbackEmail", this.feedback),
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/forgot-password-email.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { APP_NAME, EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import BaseEmail from "./_base-email";
Expand All @@ -26,7 +26,7 @@ export default class ForgotPasswordEmail extends BaseEmail {
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: `${this.passwordEvent.user.name} <${this.passwordEvent.user.email}>`,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
subject: this.passwordEvent.language("reset_password_subject", {
appName: APP_NAME,
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/monthly-digest-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { APP_NAME, EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import type { MonthlyDigestEmailData } from "../src/templates/MonthlyDigestEmail";
Expand All @@ -14,7 +14,7 @@ export default class MonthlyDigestEmail extends BaseEmail {

protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: this.eventData.admin.email,
subject: `${APP_NAME}: Your monthly digest`,
html: await renderEmail("MonthlyDigestEmail", this.eventData),
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/org-auto-join-invite.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { APP_NAME, EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "..";
import BaseEmail from "./_base-email";
Expand All @@ -25,7 +25,7 @@ export default class OrgAutoJoinEmail extends BaseEmail {
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: this.orgAutoInviteEvent.to,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
subject: this.orgAutoInviteEvent.language("user_invited_you", {
user: this.orgAutoInviteEvent.from,
team: this.orgAutoInviteEvent.orgName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import renderEmail from "../src/renderEmail";
import BaseEmail from "./_base-email";
Expand All @@ -27,7 +27,7 @@ export default class OrganizationAdminNoSlotsEmail extends BaseEmail {

protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: this.adminNoSlots.to.email,
subject: this.adminNoSlots.language("org_admin_no_slots|subject", { name: this.adminNoSlots.user }),
html: await renderEmail("OrganizationAdminNoSlotsEmail", this.adminNoSlots),
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/organization-creation-email.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import BaseEmail from "./_base-email";
Expand Down Expand Up @@ -29,7 +29,7 @@ export default class OrganizationCreationEmail extends BaseEmail {
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: this.organizationCreationEvent.to,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
subject: this.organizationCreationEvent.language(`email_organization_created|subject`),
html: await renderEmail("OrganizationCreationEmail", this.organizationCreationEvent),
text: "",
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/organization-email-verification.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import renderEmail from "../src/renderEmail";
import BaseEmail from "./_base-email";
Expand All @@ -24,7 +24,7 @@ export default class OrganizationEmailVerification extends BaseEmail {

protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: this.orgVerifyInput.user.email,
subject: this.orgVerifyInput.language("verify_email_organization"),
html: await renderEmail("OrganisationAccountVerifyEmail", this.orgVerifyInput),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import OrganizerScheduledEmail from "./organizer-scheduled-email";
Expand All @@ -16,7 +16,7 @@ export default class OrganizerCancelledEmail extends OrganizerScheduledEmail {
}

return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
subject: `${this.t("event_cancelled_subject", {
title: this.calEvent.title,
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/organizer-cancelled-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import generateIcsString from "../lib/generateIcsString";
Expand All @@ -20,7 +20,7 @@ export default class OrganizerCancelledEmail extends OrganizerScheduledEmail {
}),
method: "REQUEST",
},
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
subject: `${this.t("event_cancelled_subject", {
title: this.calEvent.title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";
import { TimeFormat } from "@calcom/lib/timeFormat";
import type { CalendarEvent } from "@calcom/types/Calendar";

Expand All @@ -22,7 +22,7 @@ export default class OrganizerDailyVideoDownloadRecordingEmail extends BaseEmail
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: `${this.calEvent.organizer.email}>`,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
replyTo: [...this.calEvent.attendees.map(({ email }) => email), this.calEvent.organizer.email],
subject: `${this.t("download_recording_subject", {
title: this.calEvent.title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { TFunction } from "next-i18next";

import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";
import { TimeFormat } from "@calcom/lib/timeFormat";
import type { CalendarEvent } from "@calcom/types/Calendar";

Expand All @@ -22,7 +22,7 @@ export default class OrganizerDailyVideoDownloadTranscriptEmail extends BaseEmai
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: `${this.calEvent.organizer.email}>`,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
replyTo: [...this.calEvent.attendees.map(({ email }) => email), this.calEvent.organizer.email],
subject: `${this.t("download_transcript_email_subject", {
title: this.calEvent.title,
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/organizer-location-change-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import generateIcsString from "../lib/generateIcsString";
Expand All @@ -20,7 +20,7 @@ export default class OrganizerLocationChangeEmail extends OrganizerScheduledEmai
}),
method: "REQUEST",
},
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
replyTo: [this.calEvent.organizer.email, ...this.calEvent.attendees.map(({ email }) => email)],
subject: `${this.t("location_changed_event_type_subject", {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import OrganizerScheduledEmail from "./organizer-scheduled-email";
Expand All @@ -8,7 +8,7 @@ export default class OrganizerPaymentRefundFailedEmail extends OrganizerSchedule
const toAddresses = [this.teamMember?.email || this.calEvent.organizer.email];

return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
subject: `${this.t("refund_failed_subject", {
eventType: this.calEvent.type,
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/organizer-request-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import OrganizerScheduledEmail from "./organizer-scheduled-email";
Expand All @@ -8,7 +8,7 @@ export default class OrganizerRequestEmail extends OrganizerScheduledEmail {
const toAddresses = [this.teamMember?.email || this.calEvent.organizer.email];

return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
replyTo: [this.calEvent.organizer.email, ...this.calEvent.attendees.map(({ email }) => email)],
subject: `${this.t("awaiting_approval")}: ${this.calEvent.title}`,
Expand Down
4 changes: 2 additions & 2 deletions packages/emails/templates/organizer-request-reminder-email.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from "@calcom/lib/constants";
import { EMAIL_FROM_NAME } from "@calcom/lib/constants";

import { renderEmail } from "../";
import OrganizerRequestEmail from "./organizer-request-email";
Expand All @@ -8,7 +8,7 @@ export default class OrganizerRequestReminderEmail extends OrganizerRequestEmail
const toAddresses = [this.teamMember?.email || this.calEvent.organizer.email];

return {
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
from: `${EMAIL_FROM_NAME} <${this.getMailerOptions().from}>`,
to: toAddresses.join(","),
replyTo: [this.calEvent.organizer.email, ...this.calEvent.attendees.map(({ email }) => email)],
subject: `${this.t("event_awaiting_approval_subject", {
Expand Down
Loading

0 comments on commit 3e10e2d

Please sign in to comment.