Skip to content

Commit

Permalink
feat(console): DKIM, DMARC & SPF records for custom domains
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmin-Parvulescu committed Jun 1, 2023
1 parent 750d4db commit 3c5b1d4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions apps/passport/app/routes/connect/email/otp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export const loader: LoaderFunction = getRollupReqFunctionErrorWrapper(
// we need to figure out DKIM
// for custom domains
// https://github.com/proofzero/rollupid/issues/2326
// if (customDomain) {
// themeProps.hostname = customDomain.hostname
// }
if (customDomain) {
themeProps.hostname = customDomain.hostname
}
}

const state = await addressClient.generateEmailOTP.mutate({
Expand Down
5 changes: 4 additions & 1 deletion platform/email/src/emailFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function send(
name: message.recipient.name,
},
],
dkim_domain: env.INTERNAL_DKIM_DOMAIN,
dkim_domain: message.customHostname ?? env.INTERNAL_DKIM_DOMAIN,
dkim_selector: env.INTERNAL_DKIM_SELECTOR,
dkim_private_key: env.KEY_DKIM_PRIVATEKEY,
},
Expand Down Expand Up @@ -94,6 +94,7 @@ export async function send(

export type NotificationSender =
| {
hostname: string
name: string
address: string
}
Expand All @@ -105,12 +106,14 @@ export async function sendNotification(
customSender?: NotificationSender
) {
let from: NotificationSender = {
hostname: env.INTERNAL_DKIM_DOMAIN,
name: env.NotificationFromName,
address: `${env.NotificationFromUser}@${env.INTERNAL_DKIM_DOMAIN}`,
}

if (customSender) {
from = {
hostname: customSender.hostname,
name: customSender.name,
address: customSender.address,
}
Expand Down
1 change: 1 addition & 0 deletions platform/email/src/jsonrpc/methods/sendOTPEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const sendEmailNotificationMethod = async ({
let customSender: NotificationSender
if (input.themeProps?.hostname) {
customSender = {
hostname: input.themeProps.hostname,
address: `no-reply@${input.themeProps.hostname}`,
name: input.themeProps.appName,
}
Expand Down
1 change: 1 addition & 0 deletions platform/email/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type EmailMessage = {
from: EmailAddressComponents
recipient: EmailAddressComponents
content: EmailContent
customHostname?: string
}

export type EmailNotification = Omit<EmailMessage, 'from'>
Expand Down

0 comments on commit 3c5b1d4

Please sign in to comment.