Fix panic on invalid smtp config

This commit is contained in:
kolaente 2021-08-02 00:05:13 +02:00
parent 4c5f457313
commit f237afd2ac
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 4 additions and 1 deletions

View File

@ -67,21 +67,24 @@ func StartMailDaemon() {
if !open {
if s, err = d.Dial(); err != nil {
log.Error("Error during connect to smtp server: %s", err)
break
}
open = true
}
if err := gomail.Send(s, m); err != nil {
log.Error("Error when sending mail: %s", err)
break
}
// Close the connection to the SMTP server if no email was sent in
// the last 30 seconds.
case <-time.After(config.MailerQueueTimeout.GetDuration() * time.Second):
if open {
open = false
if err := s.Close(); err != nil {
log.Error("Error closing the mail server connection: %s\n", err)
break
}
log.Infof("Closed connection to mailserver")
open = false
}
}
}