Skip to content

Commit

Permalink
Enable LOGIN AUTH method for legacy clients
Browse files Browse the repository at this point in the history
  • Loading branch information
mback2k committed Feb 12, 2020
1 parent 14f2de9 commit f13dfc5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.12
require (
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/emersion/go-msgauth v0.4.0
github.com/emersion/go-sasl v0.0.0-20191210011802-430746ea8b9b
github.com/emersion/go-smtp v0.12.1
github.com/emersion/go-smtp-proxy v0.0.0-20200210193521-e8e7dd723514
github.com/heroku/rollrus v0.1.1
Expand Down
13 changes: 13 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"crypto/tls"
"strings"

"github.com/emersion/go-sasl"
smtp "github.com/emersion/go-smtp"
"github.com/mholt/certmagic"
log "github.com/sirupsen/logrus"
Expand All @@ -36,6 +37,18 @@ func makeServer(cfg *config, be *backend) *smtp.Server {
s.MaxMessageBytes = cfg.MaxMessageBytes
s.MaxRecipients = cfg.MaxRecipients
s.AllowInsecureAuth = cfg.AllowInsecureAuth
s.EnableAuth(sasl.Login, func(conn *smtp.Conn) sasl.Server {
return sasl.NewLoginServer(func(username, password string) error {
state := conn.State()
session, err := be.Login(&state, username, password)
if err != nil {
return err
}

conn.SetSession(session)
return nil
})
})
return s
}

Expand Down

0 comments on commit f13dfc5

Please sign in to comment.