From ff32ff930231eb724a78379561dc6af6b9524e7a Mon Sep 17 00:00:00 2001 From: KMKoushik Date: Wed, 21 May 2025 09:44:33 +1000 Subject: [PATCH] add more logs --- apps/smtp-server/src/server.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/smtp-server/src/server.ts b/apps/smtp-server/src/server.ts index ac9af7b..30f982c 100644 --- a/apps/smtp-server/src/server.ts +++ b/apps/smtp-server/src/server.ts @@ -17,18 +17,24 @@ async function sendEmailToUnsend(emailData: any, apiKey: string) { const url = new URL(apiEndpoint, UNSEND_BASE_URL); // Combine base URL with endpoint console.log("Sending email to Unsend API at:", url.href); // Debug statement + const emailDataText = JSON.stringify(emailData); + const response = await fetch(url.href, { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", }, - body: JSON.stringify(emailData), + body: emailDataText, }); if (!response.ok) { const errorData = await response.text(); - console.error("Unsend API error response:", errorData); + console.error( + "Unsend API error response: error:", + errorData, + `\nemail data: ${emailDataText}` + ); throw new Error( `Failed to send email: ${errorData || "Unknown error from server"}` );