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.
This commit is contained in:
2025-11-02 01:17:23 +01:00
parent 9544b6800d
commit c6e60af83f
2 changed files with 16 additions and 4 deletions

View File

@@ -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;