Update mail.go

This commit is contained in:
Lizandro Guarnizo
2026-05-13 22:11:45 -05:00
parent 9bcddcf1ea
commit 96fd0c6c0e
+11 -1
View File
@@ -42,9 +42,19 @@ func (m *Mail) Send(to string, subject string, body string, ccEmails ...string)
return fmt.Errorf("MAIL_FROM_ADDRESS no está configurado")
}
// Construir el campo From con nombre si está disponible: "Nombre <email>"
fromName := m.FromName
if fromName == "" {
fromName = os.Getenv("MAIL_FROM_NAME")
}
fromHeader := from
if fromName != "" {
fromHeader = fmt.Sprintf("%s <%s>", fromName, from)
}
// Crear nuevo mensaje de correo
email := mail.NewMSG()
email.SetFrom(from).
email.SetFrom(fromHeader).
AddTo(to).
SetSubject(subject).
SetBody(mail.TextHTML, body)