Add Mailpit email transport

This commit is contained in:
2026-08-17 16:35:14 -04:00
parent 67ab6b78bd
commit 1853eaa963
23 changed files with 567 additions and 148 deletions
+4 -15
View File
@@ -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,