Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

small tweak

Kiran K3d8bce83550c
diff --git a/apps/web/.env.example b/apps/web/.env.example
index 6b1f002b56..0a7da75672 100644
--- a/apps/web/.env.example
+++ b/apps/web/.env.example
@@ -46,7 +46,6 @@ RESEND_API_KEY=
# SMTP configuration (Recommended for local development)
SMTP_HOST=localhost
SMTP_PORT=1025
-SMTP_SECURE_ENABLED=0
SMTP_USER=smtpUser
SMTP_PASSWORD=smtpPassword
diff --git a/apps/web/emails/index.ts b/apps/web/emails/index.ts
index 59d223ff8f..84ca85130f 100644
--- a/apps/web/emails/index.ts
+++ b/apps/web/emails/index.ts
@@ -10,7 +10,7 @@ const sendEmailViaSMTP = async ({
subject,
text,
react,
-}: Omit<CreateEmailOptions, "to" | "from"> & {
+}: Pick<CreateEmailOptions, "subject" | "text" | "react"> & {
email: string;
}) => {
const smtpConfigured = Boolean(
@@ -43,10 +43,10 @@ const sendEmailViaSMTP = async ({
html: render(react as ReactElement),
});
- console.log("Email sent: %s", info.messageId);
+ console.info("Email sent: %s", info.messageId);
};
-export const sendEmail = async ({
+export const sendEmailViaResend = async ({
email,
subject,
from,
@@ -62,15 +62,6 @@ export const sendEmail = async ({
replyToFromEmail?: boolean;
marketing?: boolean;
}) => {
- if (process.env.NODE_ENV === "development") {
- return await sendEmailViaSMTP({
- email,
- subject,
- text,
- react,
- });
- }
-
if (!resend) {
console.info(
"RESEND_API_KEY is not set in the .env. Skipping sending email.",
@@ -78,7 +69,7 @@ export const sendEmail = async ({
return;
}
- return resend?.emails.send({
+ return await resend.emails.send({
to: email,
from:
from ||
@@ -100,3 +91,41 @@ export const sendEmail = async ({
}),
});
};
+
+export const sendEmail = async ({
+ email,
+ subject,
+ from,
+ bcc,
+ replyToFromEmail,
+ text,
+ react,
+ scheduledAt,
+ marketing,
+}: Omit<CreateEmailOptions, "to" | "from"> & {
+ email: string;
+ from?: string;
+ replyToFromEmail?: boolean;
+ marketing?: boolean;
+}) => {
+ if (resend) {
+ return await sendEmailViaResend({
+ email,
+ subject,
+ from,
+ bcc,
+ replyToFromEmail,
+ text,
+ react,
+ scheduledAt,
+ marketing,
+ });
+ }
+
+ return await sendEmailViaSMTP({
+ email,
+ subject,
+ text,
+ react,
+ });
+};