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)