implement hello hostname to resolve smtp-relay issue

This commit is contained in:
Alexandra Stone 2023-10-27 11:33:04 -06:00 committed by GitHub
parent d2b67277e3
commit ece1c76aec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,7 @@ type SmtpMail struct {
port int port int
username string username string
password string password string
helloHostName string
authType mail.AuthType authType mail.AuthType
encryption mail.Encryption encryption mail.Encryption
noTLSCheck bool noTLSCheck bool
@ -46,8 +47,8 @@ func encryptionType(encryptionType string) mail.Encryption {
} }
} }
func NewSmtpMail(hostname string, port int, username string, password string, noTLSCheck bool, auth string, fromName, from string, encryption string) *SmtpMail { func NewSmtpMail(hostname string, port int, username string, password string, helloHostName string, noTLSCheck bool, auth string, fromName, from string, encryption string) *SmtpMail {
ans := SmtpMail{hostname: hostname, port: port, username: username, password: password, noTLSCheck: noTLSCheck, fromName: fromName, from: from, authType: authType(auth), encryption: encryptionType(encryption)} ans := SmtpMail{hostname: hostname, port: port, username: username, password: password, helloHostName: helloHostName, noTLSCheck: noTLSCheck, fromName: fromName, from: from, authType: authType(auth), encryption: encryptionType(encryption)}
return &ans return &ans
} }
@ -66,6 +67,7 @@ func (o *SmtpMail) Send(toName string, to string, subject string, content string
server.Authentication = o.authType server.Authentication = o.authType
server.Username = o.username server.Username = o.username
server.Password = o.password server.Password = o.password
server.Helo = o.helloHostName
server.Encryption = o.encryption server.Encryption = o.encryption
server.KeepAlive = false server.KeepAlive = false
server.ConnectTimeout = 10 * time.Second server.ConnectTimeout = 10 * time.Second