mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
4cadbba686
* Alerting: Allow configuration of content types for email notifications * Fix lint error * Improves email templates * Improve configuration documentation Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve code comments Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve configuration documentation Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve email template * Remove unnecessary predeclaration Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Adds handling for unrecognized content type Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Move utility function outside of util package * Fixes syntax * Remove unused package * Fix lint error * improve email templates * Fix test * Alerting: Allow configuration of content types for email notifications * Fix lint error * Improves email templates * Improve configuration documentation Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve code comments Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve configuration documentation Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Improve email template * Remove unnecessary predeclaration Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Adds handling for unrecognized content type Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Move utility function outside of util package * Fixes syntax * Remove unused package * Fix lint error * improve email templates * Fix test * Fix comment style Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> * Fix template formatting * Add test and improve error handling * Fix test * Fix formatting * Fix formatting * Improve documentation and regenerates txt template * Update docs/sources/administration/configuration.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: Djairho Geuens <djairho.geuens@ae.be> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Ganesh Vernekar <15064823+codesome@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package setting
|
|
|
|
import "github.com/grafana/grafana/pkg/util"
|
|
|
|
type SmtpSettings struct {
|
|
Enabled bool
|
|
Host string
|
|
User string
|
|
Password string
|
|
CertFile string
|
|
KeyFile string
|
|
FromAddress string
|
|
FromName string
|
|
EhloIdentity string
|
|
StartTLSPolicy string
|
|
SkipVerify bool
|
|
|
|
SendWelcomeEmailOnSignUp bool
|
|
TemplatesPatterns []string
|
|
ContentTypes []string
|
|
}
|
|
|
|
func (cfg *Cfg) readSmtpSettings() {
|
|
sec := cfg.Raw.Section("smtp")
|
|
cfg.Smtp.Enabled = sec.Key("enabled").MustBool(false)
|
|
cfg.Smtp.Host = sec.Key("host").String()
|
|
cfg.Smtp.User = sec.Key("user").String()
|
|
cfg.Smtp.Password = sec.Key("password").String()
|
|
cfg.Smtp.CertFile = sec.Key("cert_file").String()
|
|
cfg.Smtp.KeyFile = sec.Key("key_file").String()
|
|
cfg.Smtp.FromAddress = sec.Key("from_address").String()
|
|
cfg.Smtp.FromName = sec.Key("from_name").String()
|
|
cfg.Smtp.EhloIdentity = sec.Key("ehlo_identity").String()
|
|
cfg.Smtp.StartTLSPolicy = sec.Key("startTLS_policy").String()
|
|
cfg.Smtp.SkipVerify = sec.Key("skip_verify").MustBool(false)
|
|
|
|
emails := cfg.Raw.Section("emails")
|
|
cfg.Smtp.SendWelcomeEmailOnSignUp = emails.Key("welcome_email_on_sign_up").MustBool(false)
|
|
cfg.Smtp.TemplatesPatterns = util.SplitString(emails.Key("templates_pattern").MustString("emails/*.html, emails/*.txt"))
|
|
cfg.Smtp.ContentTypes = util.SplitString(emails.Key("content_types").MustString("text/html"))
|
|
}
|