Skip to content

Commit f6a32f8

Browse files
committed
feat: add EMAIL_FROM env var for configurable sender address
Allow staging and production to use different sender addresses without requiring separate Mailgun domains.
1 parent 99f2494 commit f6a32f8

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ DATABASE_URL="file:./dev.db"
1111
# Check the logs which print out the content of every "email" sent for any manual verification you need to do or links you need to open
1212
MAILGUN_SENDING_KEY=key-some-mailgun-key
1313
MAILGUN_DOMAIN=some.domain.com
14+
EMAIL_FROM=Rumah Berbagi <admin@rumahberbagi.com>
1415

1516
# Feature: authentication
1617
# Mocked: Unnecessary (any value can be used)

app/services/email.server.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import type { SendEmailFunction } from 'remix-auth-email-link'
44
import * as emailProvider from '~/services/email-provider.server'
55
import { writeFixture } from '~/utils/fixtures'
66

7+
let emailFrom = 'Rumah Berbagi <admin@rumahberbagi.com>'
8+
if (process.env.EMAIL_FROM) {
9+
emailFrom = process.env.EMAIL_FROM
10+
}
11+
712
export const sendEmail: SendEmailFunction<User> = async (options) => {
813
const subject = 'Link login untuk Kelas Rumah Berbagi'
914
const body = renderToString(
@@ -42,7 +47,7 @@ export const sendEmail: SendEmailFunction<User> = async (options) => {
4247
} else {
4348
await emailProvider.sendEmail({
4449
to: options.emailAddress,
45-
from: 'Rumah Berbagi <admin@rumahberbagi.com>',
50+
from: emailFrom,
4651
subject,
4752
html: body,
4853
})

0 commit comments

Comments
 (0)