Move SMTP HELO before authentication (#6464)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
04cd7b1a89
Коммит
9eb9c115de
@@ -50,6 +50,15 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
|
|||||||
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error())
|
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hostname := GetHostnameFromSiteURL(*config.ServiceSettings.SiteURL)
|
||||||
|
if hostname != "" {
|
||||||
|
err := c.Hello(hostname)
|
||||||
|
if err != nil {
|
||||||
|
l4g.Error(T("utils.mail.new_client.helo.error"), err)
|
||||||
|
return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.helo.app_error", nil, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
|
auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort)
|
||||||
if config.EmailSettings.ConnectionSecurity == model.CONN_SECURITY_TLS {
|
if config.EmailSettings.ConnectionSecurity == model.CONN_SECURITY_TLS {
|
||||||
if err = c.Auth(auth); err != nil {
|
if err = c.Auth(auth); err != nil {
|
||||||
@@ -136,15 +145,6 @@ func SendMailUsingConfig(to, subject, body string, config *model.Config) *model.
|
|||||||
defer c.Quit()
|
defer c.Quit()
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
siteName := GetSiteName(*config.ServiceSettings.SiteURL)
|
|
||||||
if siteName != "" {
|
|
||||||
err := c.Hello(siteName)
|
|
||||||
if err != nil {
|
|
||||||
l4g.Error(T("utils.mail.new_client.helo.error"), err)
|
|
||||||
return model.NewLocAppError("SendMail", "utils.mail.connect_smtp.helo.app_error", nil, err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := c.Mail(fromMail.Address); err != nil {
|
if err := c.Mail(fromMail.Address); err != nil {
|
||||||
return model.NewLocAppError("SendMail", "utils.mail.send_mail.from_address.app_error", nil, err.Error())
|
return model.NewLocAppError("SendMail", "utils.mail.send_mail.from_address.app_error", nil, err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func GetIpAddress(r *http.Request) string {
|
|||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSiteName(siteURL string) string {
|
func GetHostnameFromSiteURL(siteURL string) string {
|
||||||
u, err := url.Parse(siteURL)
|
u, err := url.Parse(siteURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user