Skip to content

Commit 658942d

Browse files
authored
fix(mailer): update mailer to use the EMAIL_DOMAIN (#914)
* fix(mailer): update mailer to use the EMAIL_DOMAIn * add more
1 parent 061bd6d commit 658942d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

apps/sim/app/api/help/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ ${message}
9898

9999
// Send email using Resend
100100
const { data, error } = await resend.emails.send({
101-
from: `Sim <noreply@${getEmailDomain()}>`,
102-
to: [`help@${getEmailDomain()}`],
101+
from: `Sim <noreply@${env.EMAIL_DOMAIN || getEmailDomain()}>`,
102+
to: [`help@${env.EMAIL_DOMAIN || getEmailDomain()}`],
103103
subject: `[${type.toUpperCase()}] ${subject}`,
104104
replyTo: email,
105105
text: emailText,
@@ -121,7 +121,7 @@ ${message}
121121
// Send confirmation email to the user
122122
await resend.emails
123123
.send({
124-
from: `Sim <noreply@${getEmailDomain()}>`,
124+
from: `Sim <noreply@${env.EMAIL_DOMAIN || getEmailDomain()}>`,
125125
to: [email],
126126
subject: `Your ${type} request has been received: ${subject}`,
127127
text: `
@@ -137,7 +137,7 @@ ${images.length > 0 ? `You attached ${images.length} image(s).` : ''}
137137
Best regards,
138138
The Sim Team
139139
`,
140-
replyTo: `help@${getEmailDomain()}`,
140+
replyTo: `help@${env.EMAIL_DOMAIN || getEmailDomain()}`,
141141
})
142142
.catch((err) => {
143143
logger.warn(`[${requestId}] Failed to send confirmation email`, err)

apps/sim/lib/auth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const auth = betterAuth({
165165
const html = await renderPasswordResetEmail(username, url)
166166

167167
const result = await resend.emails.send({
168-
from: `Sim <team@${getEmailDomain()}>`,
168+
from: `Sim <team@${env.EMAIL_DOMAIN || getEmailDomain()}>`,
169169
to: user.email,
170170
subject: getEmailSubject('reset-password'),
171171
html,
@@ -251,7 +251,7 @@ export const auth = betterAuth({
251251

252252
// In production, send an actual email
253253
const result = await resend.emails.send({
254-
from: `Sim <onboarding@${getEmailDomain()}>`,
254+
from: `Sim <onboarding@${env.EMAIL_DOMAIN || getEmailDomain()}>`,
255255
to: data.email,
256256
subject: getEmailSubject(data.type),
257257
html,
@@ -1512,7 +1512,7 @@ export const auth = betterAuth({
15121512
)
15131513

15141514
await resend.emails.send({
1515-
from: `Sim <team@${getEmailDomain()}>`,
1515+
from: `Sim <team@${env.EMAIL_DOMAIN || getEmailDomain()}>`,
15161516
to: invitation.email,
15171517
subject: `${inviterName} has invited you to join ${organization.name} on Sim`,
15181518
html,

apps/sim/lib/email/mailer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export async function sendEmail({
6868
}
6969
}
7070

71-
const senderEmail = from || `noreply@${getEmailDomain()}`
71+
const senderEmail = from || `noreply@${env.EMAIL_DOMAIN || getEmailDomain()}`
7272

7373
if (!resend) {
7474
logger.info('Email not sent (Resend not configured):', {
@@ -132,7 +132,7 @@ export async function sendBatchEmails({
132132
emails,
133133
}: BatchEmailOptions): Promise<BatchSendEmailResult> {
134134
try {
135-
const senderEmail = `noreply@${getEmailDomain()}`
135+
const senderEmail = `noreply@${env.EMAIL_DOMAIN || getEmailDomain()}`
136136
const results: SendEmailResult[] = []
137137

138138
if (!resend) {

0 commit comments

Comments
 (0)