summaryrefslogtreecommitdiff
path: root/internal/notifier/email.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/notifier/email.go')
-rw-r--r--internal/notifier/email.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/internal/notifier/email.go b/internal/notifier/email.go
index 4ce8d69..423b763 100644
--- a/internal/notifier/email.go
+++ b/internal/notifier/email.go
@@ -8,16 +8,20 @@ import (
"codeberg.org/snonux/gorum/internal/config"
)
-func emailNotify(conf config.Config, subject, body string) error {
+type email struct {
+ subject, body string
+}
+
+func (em email) send(conf config.Config) error {
if !conf.EmailNotifycationEnabled() {
return nil
}
- log.Println("notify:", subject, body)
+ log.Println("notify:", em.subject, em.body)
headers := map[string]string{
"From": conf.EmailFrom,
"To": conf.EmailTo,
- "Subject": subject,
+ "Subject": em.subject,
"MIME-Version": "1.0",
"Content-Type": "text/plain; charset=\"utf-8\"",
}
@@ -27,15 +31,9 @@ func emailNotify(conf config.Config, subject, body string) error {
header += fmt.Sprintf("%s: %s\r\n", k, v)
}
- message := header + "\r\n" + body
+ message := header + "\r\n" + em.body
log.Println("Using SMTP server", conf.SMTPServer)
return smtp.SendMail(conf.SMTPServer, nil, conf.EmailFrom,
[]string{conf.EmailTo}, []byte(message))
}
-
-func emailNotifyError(conf config.Config, err error) {
- if err := emailNotify(conf, fmt.Sprintf("GORUM: An error occured: %v", err), err.Error()); err != nil {
- log.Println("error:", err)
- }
-}