From 049f366e2e1e8b91da31a9a037311208bbf845a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20P=C3=A9rez?= Date: Thu, 17 Apr 2025 12:23:43 +0200 Subject: [PATCH] fix mail for using env vars --- mail/mail.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mail/mail.go b/mail/mail.go index 1a53460..eb318c4 100644 --- a/mail/mail.go +++ b/mail/mail.go @@ -15,12 +15,12 @@ type Mailer struct { smtpPass string } -func New(smtpHost string, smtpPort string, smtpUser string, smtpPass string) Mailer { +func New() Mailer { return Mailer{ - smtpHost: smtpHost, - smtpPort: smtpPort, - smtpUser: smtpUser, - smtpPass: smtpPass, + smtpHost: os.Getenv("SMTP_HOST"), + smtpPort: os.Getenv("SMTP_PORT"), + smtpUser: os.Getenv("SMTP_USER"), + smtpPass: os.Getenv("SMTP_PASS"), } } @@ -45,7 +45,7 @@ func (m *Mailer) SendMail(to []string, templateName string, data interface{}) er } func getTemplate(templateName string) string { - templatePath := "templates/" + templateName + ".gotmpl" + templatePath := "templates/mail/" + templateName + ".gotmpl" content, err := os.ReadFile(templatePath) if err != nil { fmt.Printf("Error leyendo plantilla: %v\n", err)