From 5a59e2cbeded0621c6d6aa6620bf4c4912044900 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 5 Nov 2025 04:20:24 +0000 Subject: [PATCH] completionId: cgen-17ad1e8d7d994389991d7f807f7178e5 cgen-17ad1e8d7d994389991d7f807f7178e5 --- server/index.ts | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/server/index.ts b/server/index.ts index 995823ee..e3d9fdcd 100644 --- a/server/index.ts +++ b/server/index.ts @@ -121,21 +121,40 @@ export function createServer() { (data as any)?.user?.user_metadata?.full_name ?? fullName ?? null; if (!emailService.isConfigured) { + console.warn("[API] Email service not configured. SMTP env vars missing:", { + hasHost: Boolean(process.env.SMTP_HOST), + hasUser: Boolean(process.env.SMTP_USER), + hasPassword: Boolean(process.env.SMTP_PASSWORD), + }); return res.json({ sent: false, verificationUrl: actionLink, message: - "Email service not configured. Provide RESEND_API_KEY to enable outbound email.", + "Email service not configured. Please set SMTP_HOST, SMTP_USER, and SMTP_PASSWORD to enable email sending.", }); } - await emailService.sendVerificationEmail({ - to: email, - verificationUrl: actionLink, - fullName: displayName, - }); - - return res.json({ sent: true, verificationUrl: actionLink }); + try { + await emailService.sendVerificationEmail({ + to: email, + verificationUrl: actionLink, + fullName: displayName, + }); + console.log("[API] Verification email sent successfully to:", email); + return res.json({ sent: true, verificationUrl: actionLink }); + } catch (emailError: any) { + console.error("[API] sendVerificationEmail threw error:", { + message: emailError?.message || String(emailError), + code: emailError?.code || null, + response: emailError?.response || null, + }); + // Return with manual link as fallback even if email fails + return res.status(200).json({ + sent: false, + verificationUrl: actionLink, + message: `Email delivery failed: ${emailError?.message || "SMTP error"}. Use manual link to verify.`, + }); + } } catch (error: any) { console.error("[API] send verification email failed", error); return res