Add dotenv package for environment variable management and refactor SMTP credential handling in email services. Enhance error handling for missing SMTP credentials across various API endpoints to improve reliability and maintainability.

This commit is contained in:
Torsten Schulz (local)
2025-12-18 12:19:23 +01:00
parent 4d9f099907
commit 2dc0bc7d67
12 changed files with 492 additions and 95 deletions

View File

@@ -22,13 +22,23 @@ export default defineEventHandler(async (event) => {
}
// SMTP-Konfiguration (hier können Sie Ihre SMTP-Daten eintragen)
const smtpUser = process.env.SMTP_USER || 'j.dichmann@gmx.de'
const smtpPass = process.env.SMTP_PASS || process.env.EMAIL_PASSWORD
if (!smtpUser || !smtpPass) {
throw createError({
statusCode: 500,
statusMessage: 'SMTP-Credentials fehlen! Bitte setzen Sie SMTP_USER und SMTP_PASS in der .env Datei.'
})
}
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST || 'smtp.gmail.com',
port: process.env.SMTP_PORT || 587,
secure: false, // true für 465, false für andere Ports
auth: {
user: process.env.SMTP_USER || 'j.dichmann@gmx.de',
pass: process.env.SMTP_PASS || process.env.EMAIL_PASSWORD
user: smtpUser,
pass: smtpPass
}
})