From cc8cd09f8ba3ccd26b9e536f1497e423534a9af9 Mon Sep 17 00:00:00 2001 From: Taufik Date: Wed, 19 Jan 2022 14:56:39 +0700 Subject: [PATCH] by default Set Helo as sender domain --- email.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/email.go b/email.go index 64af7b5..15e419e 100644 --- a/email.go +++ b/email.go @@ -9,6 +9,7 @@ import ( "net/mail" "net/textproto" "strconv" + "strings" "time" "github.com/toorop/go-dkim" @@ -786,6 +787,13 @@ func (server *SMTPServer) Connect() (*SMTPClient, error) { tlsConfig = &tls.Config{ServerName: server.Host} } + if server.Helo == "" { + atIndex := strings.LastIndex(server.Username, "@") + if atIndex >= 0 { + server.Helo = server.Username[atIndex+1:] + } + } + // if there is a ConnectTimeout, setup the channel and do the connect under a goroutine if server.ConnectTimeout != 0 { smtpConnectChannel = make(chan error, 2)