From 6251b46b6f403d6c62a6f2174bfc2b78345beb2d Mon Sep 17 00:00:00 2001 From: kannan-nic <168638714+kannan-nic@users.noreply.github.com> Date: Thu, 2 May 2024 10:25:01 +0530 Subject: [PATCH] Update smtp.go Signed-off-by: kannan-nic <168638714+kannan-nic@users.noreply.github.com> --- connector/smtp/smtp.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/connector/smtp/smtp.go b/connector/smtp/smtp.go index 80982e5df1..d1ef13b404 100644 --- a/connector/smtp/smtp.go +++ b/connector/smtp/smtp.go @@ -37,9 +37,11 @@ func (sc *smtpConnector) Login(ctx context.Context, _ connector.Scopes, username // Dial var conn net.Conn - - if p == "" || p == "25" { + + if strings.Contains(p, "tls") { + sc.cfg.Host = sc.cfg.Host[0 : len(sc.cfg.Host)-3] + p = p[0 : len(p)-3] tlsconfig := &tls.Config { InsecureSkipVerify: true, ServerName: h, @@ -49,6 +51,12 @@ func (sc *smtpConnector) Login(ctx context.Context, _ connector.Scopes, username if err != nil { return } + } + else if p == "" || p == "465" { + conn, err = tls.Dial("tcp", sc.cfg.Host, nil) + if err != nil { + return + } } else { conn, err = net.Dial("tcp", sc.cfg.Host) if err != nil {