Merge pull request #9341 from thz/smtp_ehlo_identity

introduce smtp config option for EHLO identity
This commit is contained in:
Carl Bergquist 2017-09-24 21:41:57 +02:00 committed by GitHub
commit 9aa4f5c42a
6 changed files with 23 additions and 10 deletions

View File

@ -318,6 +318,7 @@ key_file =
skip_verify = false skip_verify = false
from_address = admin@grafana.localhost from_address = admin@grafana.localhost
from_name = Grafana from_name = Grafana
ehlo_identity =
[emails] [emails]
welcome_email_on_sign_up = false welcome_email_on_sign_up = false

View File

@ -295,6 +295,8 @@
;skip_verify = false ;skip_verify = false
;from_address = admin@grafana.localhost ;from_address = admin@grafana.localhost
;from_name = Grafana ;from_name = Grafana
# EHLO identity in SMTP dialog (defaults to instance_name)
;ehlo_identity = dashboard.example.com
[emails] [emails]
;welcome_email_on_sign_up = false ;welcome_email_on_sign_up = false

View File

@ -161,6 +161,7 @@ Only works with Basic Authentication (username and password). See [introduction]
"enabled":"false", "enabled":"false",
"from_address":"admin@grafana.localhost", "from_address":"admin@grafana.localhost",
"from_name":"Grafana", "from_name":"Grafana",
"ehlo_identity":"dashboard.example.com",
"host":"localhost:25", "host":"localhost:25",
"key_file":"", "key_file":"",
"password":"************", "password":"************",

View File

@ -593,6 +593,9 @@ Address used when sending out emails, defaults to `admin@grafana.localhost`
### from_name ### from_name
Name to be used when sending out emails, defaults to `Grafana` Name to be used when sending out emails, defaults to `Grafana`
### ehlo_identity
Name to be used as client identity for EHLO in SMTP dialog, defaults to instance_name.
## [log] ## [log]
### mode ### mode

View File

@ -101,7 +101,11 @@ func createDialer() (*gomail.Dialer, error) {
d := gomail.NewDialer(host, iPort, setting.Smtp.User, setting.Smtp.Password) d := gomail.NewDialer(host, iPort, setting.Smtp.User, setting.Smtp.Password)
d.TLSConfig = tlsconfig d.TLSConfig = tlsconfig
d.LocalName = setting.InstanceName if setting.Smtp.EhloIdentity != "" {
d.LocalName = setting.Smtp.EhloIdentity
} else {
d.LocalName = setting.InstanceName
}
return d, nil return d, nil
} }

View File

@ -1,15 +1,16 @@
package setting package setting
type SmtpSettings struct { type SmtpSettings struct {
Enabled bool Enabled bool
Host string Host string
User string User string
Password string Password string
CertFile string CertFile string
KeyFile string KeyFile string
FromAddress string FromAddress string
FromName string FromName string
SkipVerify bool EhloIdentity string
SkipVerify bool
SendWelcomeEmailOnSignUp bool SendWelcomeEmailOnSignUp bool
TemplatesPattern string TemplatesPattern string
@ -25,6 +26,7 @@ func readSmtpSettings() {
Smtp.KeyFile = sec.Key("key_file").String() Smtp.KeyFile = sec.Key("key_file").String()
Smtp.FromAddress = sec.Key("from_address").String() Smtp.FromAddress = sec.Key("from_address").String()
Smtp.FromName = sec.Key("from_name").String() Smtp.FromName = sec.Key("from_name").String()
Smtp.EhloIdentity = sec.Key("ehlo_identity").String()
Smtp.SkipVerify = sec.Key("skip_verify").MustBool(false) Smtp.SkipVerify = sec.Key("skip_verify").MustBool(false)
emails := Cfg.Section("emails") emails := Cfg.Section("emails")