Update mail.go
This commit is contained in:
+11
-1
@@ -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")
|
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
|
// Crear nuevo mensaje de correo
|
||||||
email := mail.NewMSG()
|
email := mail.NewMSG()
|
||||||
email.SetFrom(from).
|
email.SetFrom(fromHeader).
|
||||||
AddTo(to).
|
AddTo(to).
|
||||||
SetSubject(subject).
|
SetSubject(subject).
|
||||||
SetBody(mail.TextHTML, body)
|
SetBody(mail.TextHTML, body)
|
||||||
|
|||||||
Reference in New Issue
Block a user