Add Mailpit email transport
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { Resend } from "resend";
|
||||
import { env } from "~/env";
|
||||
import { APP_EMAIL_DOMAIN } from "~/lib/app-email";
|
||||
import { sendEmail } from "@beenvoice/email";
|
||||
import { getAppUrl } from "~/lib/app-url";
|
||||
import { generatePasswordResetEmailTemplate } from "~/lib/email-templates";
|
||||
import {
|
||||
@@ -10,6 +8,7 @@ import {
|
||||
} from "~/lib/reset-token";
|
||||
import { db } from "~/server/db";
|
||||
import { users } from "~/server/db/schema";
|
||||
import { resolveEmailSender } from "~/server/services/email-sender";
|
||||
|
||||
export type PasswordResetResult = {
|
||||
success: boolean;
|
||||
@@ -22,15 +21,7 @@ export async function sendPasswordResetEmail(input: {
|
||||
userName?: string;
|
||||
resetToken: string;
|
||||
}): Promise<PasswordResetResult> {
|
||||
if (!env.RESEND_API_KEY) {
|
||||
console.warn(
|
||||
"Password reset requested, but RESEND_API_KEY is not configured.",
|
||||
);
|
||||
return { success: true, emailSent: false, userEmail: input.userEmail };
|
||||
}
|
||||
|
||||
try {
|
||||
const resend = new Resend(env.RESEND_API_KEY);
|
||||
const resetUrl = `${getAppUrl()}/auth/reset-password?token=${input.resetToken}`;
|
||||
const emailTemplate = generatePasswordResetEmailTemplate({
|
||||
userEmail: input.userEmail,
|
||||
@@ -39,10 +30,8 @@ export async function sendPasswordResetEmail(input: {
|
||||
resetUrl,
|
||||
expiryHours: 1,
|
||||
});
|
||||
const fromDomain = env.RESEND_DOMAIN ?? APP_EMAIL_DOMAIN;
|
||||
|
||||
await resend.emails.send({
|
||||
from: `beenvoice <noreply@${fromDomain}>`,
|
||||
await sendEmail({
|
||||
...resolveEmailSender(null, "beenvoice"),
|
||||
to: input.userEmail,
|
||||
subject: emailTemplate.subject,
|
||||
html: emailTemplate.html,
|
||||
|
||||
Reference in New Issue
Block a user