Skip to content

Commit 3aacc9b

Browse files
wxiaoguanglunny
andauthored
Revert unrelated changes for SMTP auth (#21767) (#21768)
Backport #21767 The purpose of #18982 is to improve the SMTP mailer, but there were some unrelated changes made to the SMTP auth in d60c438 This PR reverts these unrelated changes, fix #21744 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
1 parent 87d05d3 commit 3aacc9b

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

Diff for: cmd/admin.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ var (
413413
Usage: "SMTP Authentication Type (PLAIN/LOGIN/CRAM-MD5) default PLAIN",
414414
},
415415
cli.StringFlag{
416-
Name: "addr",
416+
Name: "host",
417417
Value: "",
418-
Usage: "SMTP Addr",
418+
Usage: "SMTP Host",
419419
},
420420
cli.IntFlag{
421421
Name: "port",
@@ -955,8 +955,8 @@ func parseSMTPConfig(c *cli.Context, conf *smtp.Source) error {
955955
}
956956
conf.Auth = c.String("auth-type")
957957
}
958-
if c.IsSet("addr") {
959-
conf.Addr = c.String("addr")
958+
if c.IsSet("host") {
959+
conf.Host = c.String("host")
960960
}
961961
if c.IsSet("port") {
962962
conf.Port = c.Int("port")

Diff for: routers/web/admin/auths.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func parseLDAPConfig(form forms.AuthenticationForm) *ldap.Source {
159159
func parseSMTPConfig(form forms.AuthenticationForm) *smtp.Source {
160160
return &smtp.Source{
161161
Auth: form.SMTPAuth,
162-
Addr: form.SMTPAddr,
162+
Host: form.SMTPHost,
163163
Port: form.SMTPPort,
164164
AllowedDomains: form.AllowedDomains,
165165
ForceSMTPS: form.ForceSMTPS,

Diff for: services/auth/source/smtp/auth.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ var ErrUnsupportedLoginType = errors.New("Login source is unknown")
5858
func Authenticate(a smtp.Auth, source *Source) error {
5959
tlsConfig := &tls.Config{
6060
InsecureSkipVerify: source.SkipVerify,
61-
ServerName: source.Addr,
61+
ServerName: source.Host,
6262
}
6363

64-
conn, err := net.Dial("tcp", net.JoinHostPort(source.Addr, strconv.Itoa(source.Port)))
64+
conn, err := net.Dial("tcp", net.JoinHostPort(source.Host, strconv.Itoa(source.Port)))
6565
if err != nil {
6666
return err
6767
}
@@ -71,7 +71,7 @@ func Authenticate(a smtp.Auth, source *Source) error {
7171
conn = tls.Client(conn, tlsConfig)
7272
}
7373

74-
client, err := smtp.NewClient(conn, source.Addr)
74+
client, err := smtp.NewClient(conn, source.Host)
7575
if err != nil {
7676
return fmt.Errorf("failed to create NewClient: %w", err)
7777
}

Diff for: services/auth/source/smtp/source.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
// Source holds configuration for the SMTP login source.
2020
type Source struct {
2121
Auth string
22-
Addr string
22+
Host string
2323
Port int
2424
AllowedDomains string `xorm:"TEXT"`
2525
ForceSMTPS bool

Diff for: services/auth/source/smtp/source_authenticate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (source *Source) Authenticate(user *user_model.User, userName, password str
3232
var auth smtp.Auth
3333
switch source.Auth {
3434
case PlainAuthentication:
35-
auth = smtp.PlainAuth("", userName, password, source.Addr)
35+
auth = smtp.PlainAuth("", userName, password, source.Host)
3636
case LoginAuthentication:
3737
auth = &loginAuthenticator{userName, password}
3838
case CRAMMD5Authentication:

Diff for: services/forms/auth_form.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type AuthenticationForm struct {
4545
IsActive bool
4646
IsSyncEnabled bool
4747
SMTPAuth string
48-
SMTPAddr string
48+
SMTPHost string
4949
SMTPPort int
5050
AllowedDomains string
5151
SecurityProtocol int `binding:"Range(0,2)"`

0 commit comments

Comments
 (0)