implement PLT-6469 - Send HELO request containing domain name to SMTP server (#6322)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
622998add1
Коммит
0df61d161f
@@ -5902,6 +5902,10 @@
|
|||||||
{
|
{
|
||||||
"id": "utils.mail.connect_smtp.open_tls.app_error",
|
"id": "utils.mail.connect_smtp.open_tls.app_error",
|
||||||
"translation": "Failed to open TLS connection"
|
"translation": "Failed to open TLS connection"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "utils.mail.connect_smtp.helo.app_error",
|
||||||
|
"translation": "Failed to set HELO"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "utils.mail.new_client.auth.app_error",
|
"id": "utils.mail.new_client.auth.app_error",
|
||||||
@@ -5911,6 +5915,10 @@
|
|||||||
"id": "utils.mail.new_client.open.error",
|
"id": "utils.mail.new_client.open.error",
|
||||||
"translation": "Failed to open a connection to SMTP server %v"
|
"translation": "Failed to open a connection to SMTP server %v"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "utils.mail.new_client.helo.error",
|
||||||
|
"translation": "Failed to to set the HELO to SMTP server %v"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "utils.mail.send_mail.close.app_error",
|
"id": "utils.mail.send_mail.close.app_error",
|
||||||
"translation": "Failed to close connection to SMTP server"
|
"translation": "Failed to close connection to SMTP server"
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap
|
|||||||
l4g.Error(T("utils.mail.new_client.open.error"), err)
|
l4g.Error(T("utils.mail.new_client.open.error"), err)
|
||||||
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())
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
@@ -135,6 +136,15 @@ 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())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/mattermost/platform/model"
|
"github.com/mattermost/platform/model"
|
||||||
@@ -66,3 +67,11 @@ func GetIpAddress(r *http.Request) string {
|
|||||||
|
|
||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetSiteName(siteURL string) string {
|
||||||
|
u, err := url.Parse(siteURL)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return u.Host
|
||||||
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user