fix(mail): do not fail testmail command when the connection could not be closed.
Resolves https://github.com/go-vikunja/vikunja/issues/300 (cherry picked from commit 40bb86bee59585f827752e96c87e5e8c8f81495c)
This commit is contained in:
parent
42ba9240b0
commit
950de7c954
@ -17,6 +17,8 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"code.vikunja.io/api/pkg/config"
|
"code.vikunja.io/api/pkg/config"
|
||||||
"code.vikunja.io/api/pkg/initialize"
|
"code.vikunja.io/api/pkg/initialize"
|
||||||
"code.vikunja.io/api/pkg/log"
|
"code.vikunja.io/api/pkg/log"
|
||||||
@ -51,10 +53,11 @@ var testmailCmd = &cobra.Command{
|
|||||||
|
|
||||||
opts, err := notifications.RenderMail(message)
|
opts, err := notifications.RenderMail(message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error sending test mail: %s", err.Error())
|
log.Errorf("Error rendering test mail: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := mail.SendTestMail(opts); err != nil {
|
if err := mail.SendTestMail(opts); err != nil &&
|
||||||
|
strings.HasPrefix(err.Error(), "failed to close connction: not connected to SMTP server") {
|
||||||
log.Errorf("Error sending test mail: %s", err.Error())
|
log.Errorf("Error sending test mail: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package mail
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"code.vikunja.io/api/pkg/config"
|
"code.vikunja.io/api/pkg/config"
|
||||||
@ -60,8 +61,7 @@ type header struct {
|
|||||||
// It works without a queue.
|
// It works without a queue.
|
||||||
func SendTestMail(opts *Opts) error {
|
func SendTestMail(opts *Opts) error {
|
||||||
if config.MailerHost.GetString() == "" {
|
if config.MailerHost.GetString() == "" {
|
||||||
log.Warning("Mailer seems to be not configured! Please see the config docs for more details.")
|
return fmt.Errorf("mailer is not configured! Please see the config docs for more details")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := getClient()
|
c, err := getClient()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user