From c6e60af83f2df3eb515dbd88a0574541f15559e2 Mon Sep 17 00:00:00 2001 From: Richard Bergsma Date: Sun, 2 Nov 2025 01:17:23 +0100 Subject: [PATCH] Initialize environment variables and enhance email configuration logging - Added dotenv to load environment variables from a .env file in server.js. - Updated SMTP configuration in email-handler.ts with default values for better development setup. - Implemented debug logging for email configuration to assist in troubleshooting during development. --- server.js | 4 ++++ src/utils/email-handler.ts | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index b0edcc6..21b7db2 100644 --- a/server.js +++ b/server.js @@ -1,3 +1,7 @@ +// Load environment variables from .env file first +import dotenv from 'dotenv'; +dotenv.config(); + import express from 'express'; import compression from 'compression'; import { handler } from './dist/server/entry.mjs'; diff --git a/src/utils/email-handler.ts b/src/utils/email-handler.ts index 50f90c8..0b69134 100644 --- a/src/utils/email-handler.ts +++ b/src/utils/email-handler.ts @@ -7,17 +7,25 @@ import path from 'path'; // Environment variables const { - SMTP_HOST = '', + SMTP_HOST = 'mailcowdockerized-postfix-mailcow-1', SMTP_PORT = '587', - SMTP_USER = '', - SMTP_PASS = '', - ADMIN_EMAIL = '', + SMTP_USER = 'test@devnet365.eu', + SMTP_PASS = 'Liable7-Flavored6-Path0-Diligent0-Fragrant7', + ADMIN_EMAIL = 'info@devnet365.eu', WEBSITE_NAME = '365DevNet Support', } = process.env; // Email configuration const isProduction = process.env.NODE_ENV === 'production'; +// Debug: Log environment variables on load (only in development or if SMTP_HOST is set) +if (!isProduction || SMTP_HOST) { + console.log('[EMAIL CONFIG] SMTP_HOST:', SMTP_HOST || '(not set)'); + console.log('[EMAIL CONFIG] SMTP_PORT:', SMTP_PORT || '(using default: 587)'); + console.log('[EMAIL CONFIG] SMTP_USER:', SMTP_USER ? '***' : '(not set - no auth)'); + console.log('[EMAIL CONFIG] ADMIN_EMAIL:', ADMIN_EMAIL || '(not set)'); +} + // Create a transporter for sending emails let transporter: nodemailer.Transporter;