Email: Allow configuration of content types for email notifications (#34530)
* 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>
This commit is contained in:
co-authored by
Diana Payton
Arve Knudsen
Ganesh Vernekar
achatterjee-grafana
Djairho Geuens
parent
cec12676e7
commit
4cadbba686
@@ -19,9 +19,9 @@ import (
|
||||
)
|
||||
|
||||
var mailTemplates *template.Template
|
||||
var tmplResetPassword = "reset_password.html"
|
||||
var tmplSignUpStarted = "signup_started.html"
|
||||
var tmplWelcomeOnSignUp = "welcome_on_signup.html"
|
||||
var tmplResetPassword = "reset_password"
|
||||
var tmplSignUpStarted = "signup_started"
|
||||
var tmplWelcomeOnSignUp = "welcome_on_signup"
|
||||
|
||||
func init() {
|
||||
registry.RegisterService(&NotificationService{})
|
||||
@@ -56,10 +56,12 @@ func (ns *NotificationService) Init() error {
|
||||
"Subject": subjectTemplateFunc,
|
||||
})
|
||||
|
||||
templatePattern := filepath.Join(ns.Cfg.StaticRootPath, ns.Cfg.Smtp.TemplatesPattern)
|
||||
_, err := mailTemplates.ParseGlob(templatePattern)
|
||||
if err != nil {
|
||||
return err
|
||||
for _, pattern := range ns.Cfg.Smtp.TemplatesPatterns {
|
||||
templatePattern := filepath.Join(ns.Cfg.StaticRootPath, pattern)
|
||||
_, err := mailTemplates.ParseGlob(templatePattern)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !util.IsEmail(ns.Cfg.Smtp.FromAddress) {
|
||||
|
||||
Reference in New Issue
Block a user