Commit 5fca4c73 by Daniel Lee Committed by GitHub

Merge pull request #7569 from jacobbednarz/add-sender-name-to-email

Updates mailer to include `from_name` value
parents 8b25ba6a 6a924750
......@@ -296,6 +296,7 @@ cert_file =
key_file =
skip_verify = false
from_address = admin@grafana.localhost
from_name = Grafana Admin
[emails]
welcome_email_on_sign_up = false
......
......@@ -282,6 +282,7 @@
;key_file =
;skip_verify = false
;from_address = admin@grafana.localhost
;from_name = Grafana Admin
[emails]
;welcome_email_on_sign_up = false
......
......@@ -158,6 +158,7 @@ with Grafana admin permission.
"cert_file":"",
"enabled":"false",
"from_address":"admin@grafana.localhost",
"from_name":"Grafana Admin",
"host":"localhost:25",
"key_file":"",
"password":"************",
......
......@@ -542,6 +542,9 @@ Verify SSL for smtp server? defaults to `false`
### from_address
Address used when sending out emails, defaults to `admin@grafana.localhost`
### from_name
Name to be used when sending out emails, defaults to `Grafana Admin`
## [log]
### mode
......
......@@ -150,7 +150,7 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) {
return &Message{
To: cmd.To,
From: setting.Smtp.FromAddress,
From: fmt.Sprintf("%s <%s>", setting.Smtp.FromName, setting.Smtp.FromAddress),
Subject: subject,
Body: buffer.String(),
EmbededFiles: cmd.EmbededFiles,
......
......@@ -48,7 +48,7 @@ func Init() error {
}
if !util.IsEmail(setting.Smtp.FromAddress) {
return errors.New("Invalid email address for smpt from_adress config")
return errors.New("Invalid email address for SMTP from_address config")
}
if setting.EmailCodeValidMinutes == 0 {
......
......@@ -23,6 +23,7 @@ func TestNotifications(t *testing.T) {
setting.Smtp.Enabled = true
setting.Smtp.TemplatesPattern = "emails/*.html"
setting.Smtp.FromAddress = "from@address.com"
setting.Smtp.FromName = "Grafana Admin"
err := Init()
So(err, ShouldBeNil)
......
......@@ -18,6 +18,7 @@ func TestEmailIntegrationTest(t *testing.T) {
setting.Smtp.Enabled = true
setting.Smtp.TemplatesPattern = "emails/*.html"
setting.Smtp.FromAddress = "from@address.com"
setting.Smtp.FromName = "Grafana Admin"
setting.BuildVersion = "4.0.0"
err := Init()
......
......@@ -8,6 +8,7 @@ type SmtpSettings struct {
CertFile string
KeyFile string
FromAddress string
FromName string
SkipVerify bool
SendWelcomeEmailOnSignUp bool
......@@ -23,6 +24,7 @@ func readSmtpSettings() {
Smtp.CertFile = sec.Key("cert_file").String()
Smtp.KeyFile = sec.Key("key_file").String()
Smtp.FromAddress = sec.Key("from_address").String()
Smtp.FromName = sec.Key("from_name").String()
Smtp.SkipVerify = sec.Key("skip_verify").MustBool(false)
emails := Cfg.Section("emails")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment