1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-24 13:48:49 +08:00

MF-1521 - Fix email headers (#1522)

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
This commit is contained in:
Ivan Milošević 2021-12-08 10:48:05 +01:00 committed by GitHub
parent db6fab961e
commit 309ef512cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 4 deletions

View File

@ -309,6 +309,7 @@ MF_SMTP_NOTIFIER_DB_USER=mainflux
MF_SMTP_NOTIFIER_DB_PASS=mainflux
MF_SMTP_NOTIFIER_DB=subscriptions
MF_SMTP_NOTIFIER_TEMPLATE=smtp-notifier.tmpl
MF_SMTP_NOTIFIER_FROM_ADDR=from@example.com
### SMPP Notifier

View File

@ -55,6 +55,7 @@ services:
MF_EMAIL_FROM_NAME: ${MF_EMAIL_FROM_NAME}
MF_EMAIL_TEMPLATE: ${MF_EMAIL_TEMPLATE}
MF_SMTP_NOTIFIER_TEMPLATE: ${MF_SMTP_NOTIFIER_TEMPLATE}
MF_SMTP_NOTIFIER_FROM_ADDR: ${MF_SMTP_NOTIFIER_FROM_ADDR}
ports:
- ${MF_SMTP_NOTIFIER_PORT}:${MF_SMTP_NOTIFIER_PORT}
networks:

View File

@ -1,4 +1,4 @@
To: {{.To}}
To: {{range $index, $v := .To}}{{if $index}},{{end}}{{$v}}{{end}}
From: {{.From}}
Subject: {{.Subject}}
{{.Header}}

View File

@ -1,4 +1,4 @@
To: {{.To}}
To: {{range $index, $v := .To}}{{if $index}},{{end}}{{$v}}{{end}}
From: {{.From}}
Subject: {{.Subject}}
{{.Header}}

View File

@ -6,8 +6,9 @@ package email
import (
"bytes"
"fmt"
"html/template"
"net/mail"
"net/smtp"
"text/template"
"github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/pkg/errors"
@ -89,7 +90,8 @@ func (a *Agent) Send(To []string, From, Subject, Header, Content, Footer string)
Footer: Footer,
}
if From == "" {
tmpl.From = a.conf.FromName
from := mail.Address{Name: a.conf.FromName, Address: a.conf.FromAddress}
tmpl.From = from.String()
}
if err := a.tmpl.Execute(email, tmpl); err != nil {