Password email not sent (#34)

* Sending mails from password reset

now we are really sending the mail
* Must set Mail configuration
This commit is contained in:
Bardioc26
2026-02-17 23:12:58 +01:00
committed by GitHub
parent 1084a16eae
commit a7eb3cda81
6 changed files with 425 additions and 20 deletions
+34
View File
@@ -32,6 +32,13 @@ type Config struct {
// PDF Templates
TemplatesDir string // Directory where PDF templates are stored
ExportTempDir string // Directory for temporary PDF exports
// Mail Configuration
MailHost string // SMTP server host
MailPort int // SMTP server port
MailUsername string // SMTP username
MailPassword string // SMTP password
MailFrom string // Default sender email address
}
// Cfg ist die globale Konfigurationsvariable
@@ -56,6 +63,11 @@ func defaultConfig() *Config {
FrontendURL: "http://localhost:5173", // Default frontend URL for development
TemplatesDir: "./templates", // Default templates directory
ExportTempDir: "./xporttemp", // Default export temp directory
MailHost: "", // No default, must be configured
MailPort: 465, // Default SMTP SSL port
MailUsername: "", // No default, must be configured
MailPassword: "", // No default, must be configured
MailFrom: "", // No default, must be configured
}
}
@@ -136,6 +148,28 @@ func LoadConfig() *Config {
config.ExportTempDir = exportTempDir
}
// Mail Configuration
if mailHost := os.Getenv("MAIL_HOST"); mailHost != "" {
config.MailHost = mailHost
}
if mailPort := os.Getenv("MAIL_PORT"); mailPort != "" {
if port, err := strconv.Atoi(mailPort); err == nil {
config.MailPort = port
}
}
if mailUsername := os.Getenv("MAIL_USERNAME"); mailUsername != "" {
config.MailUsername = mailUsername
}
if mailPassword := os.Getenv("MAIL_PASSWORD"); mailPassword != "" {
config.MailPassword = mailPassword
}
if mailFrom := os.Getenv("MAIL_FROM"); mailFrom != "" {
config.MailFrom = mailFrom
} else if config.MailUsername != "" {
// Fallback: Verwende Username als From-Adresse
config.MailFrom = config.MailUsername
}
fmt.Printf("DEBUG LoadConfig - Finale Config: Environment='%s', DevTesting='%s', DatabaseType='%s'\n Complete: %v\n",
config.Environment, config.DevTesting, config.DatabaseType, config)