瀏覽代碼

fix(smtp mailer): added timeout of 10 seconds to smpt mailer, fixes #2989

Torkel Ödegaard 9 年之前
父節點
當前提交
e336fb3d60
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      pkg/services/notifications/mailer.go

+ 2 - 1
pkg/services/notifications/mailer.go

@@ -12,6 +12,7 @@ import (
 	"net/smtp"
 	"net/smtp"
 	"os"
 	"os"
 	"strings"
 	"strings"
+	"time"
 
 
 	"github.com/grafana/grafana/pkg/log"
 	"github.com/grafana/grafana/pkg/log"
 	"github.com/grafana/grafana/pkg/setting"
 	"github.com/grafana/grafana/pkg/setting"
@@ -66,7 +67,7 @@ func sendToSmtpServer(recipients []string, msgContent []byte) error {
 		tlsconfig.Certificates = []tls.Certificate{cert}
 		tlsconfig.Certificates = []tls.Certificate{cert}
 	}
 	}
 
 
-	conn, err := net.Dial("tcp", net.JoinHostPort(host, port))
+	conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), time.Second*10)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}