forked from dubinc/dub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d73151c
commit 3f63a52
Showing
7 changed files
with
1,580 additions
and
1,162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import { render } from "@react-email/render"; | ||
import { Client } from "postmark"; | ||
import { JSXElementConstructor, ReactElement } from "react"; | ||
|
||
export const client = process.env.POSTMARK_API_KEY | ||
? new Client(process.env.POSTMARK_API_KEY) | ||
: null; | ||
import { Resend } from "resend"; | ||
|
||
export const client = new Resend(process.env.RESEND_API_KEY); | ||
|
||
export const sendEmail = async ({ | ||
email, | ||
|
@@ -35,31 +33,28 @@ export const sendEmail = async ({ | |
return Promise.resolve(); | ||
} else if (!client) { | ||
console.error( | ||
"Postmark is not configured. You need to add a POSTMARK_API_KEY in your .env file for emails to work.", | ||
"Resend is not configured. You need to add a RESEND_API_KEY in your .env file for emails to work.", | ||
); | ||
return Promise.resolve(); | ||
} | ||
|
||
return client.sendEmail({ | ||
From: | ||
return client.emails.send({ | ||
from: | ||
from || | ||
(marketing | ||
? "[email protected]" | ||
: process.env.NEXT_PUBLIC_IS_DUB | ||
? "[email protected]" | ||
: `${process.env.NEXT_PUBLIC_APP_NAME} <system@${process.env.NEXT_PUBLIC_APP_DOMAIN}>`), | ||
To: email, | ||
Bcc: bcc, | ||
to: email, | ||
bcc: bcc, | ||
...(!replyToFromEmail && { | ||
ReplyTo: process.env.NEXT_PUBLIC_IS_DUB | ||
replyTo: process.env.NEXT_PUBLIC_IS_DUB | ||
? "[email protected]" | ||
: `support@${process.env.NEXT_PUBLIC_APP_DOMAIN}`, | ||
}), | ||
Subject: subject, | ||
...(text && { TextBody: text }), | ||
...(react && { HtmlBody: render(react) }), | ||
...(marketing && { | ||
MessageStream: "broadcast", | ||
}), | ||
subject: subject, | ||
text: text, | ||
react: react, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
"use server"; | ||
|
||
import { render } from "@react-email/render"; | ||
import { client } from "emails"; | ||
import FeedbackEmail from "emails/feedback-email"; | ||
|
||
export async function submitFeedback(data: FormData) { | ||
const email = data.get("email") as string; | ||
const feedback = data.get("feedback") as string; | ||
|
||
const emailHtml = render(FeedbackEmail({ email, feedback })); | ||
|
||
return await client?.sendEmail({ | ||
From: "[email protected]", | ||
To: "[email protected]", | ||
...(email && { ReplyTo: email }), | ||
Subject: "🎉 New Feedback Received!", | ||
HtmlBody: emailHtml, | ||
return await client.emails.send({ | ||
from: "[email protected]", | ||
to: "[email protected]", | ||
...(email && { replyTo: email }), | ||
subject: "🎉 New Feedback Received!", | ||
react: FeedbackEmail({ email, feedback }), | ||
}); | ||
} |
Oops, something went wrong.