Fix anonymous login

This commit is contained in:
wpetit 2020-06-17 23:48:32 +02:00
parent 66a06c9bf4
commit f2530bf390
1 changed files with 8 additions and 1 deletions

View File

@ -43,7 +43,9 @@ func (b *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, err
return nil, smtp.ErrAuthRequired return nil, smtp.ErrAuthRequired
} }
return nil, nil ctx := context.WithValue(context.Background(), container.KeyServiceContainer, b.ctn)
return &Session{ctx, b.ctn, "anonymous"}, nil
} }
// A Session is returned after successful login. // A Session is returned after successful login.
@ -105,6 +107,11 @@ func startSMTPServer(conf *config.Config, ctn *service.Container) {
s.MaxMessageBytes = conf.SMTP.MaxMessageBytes s.MaxMessageBytes = conf.SMTP.MaxMessageBytes
s.MaxRecipients = conf.SMTP.MaxRecipients s.MaxRecipients = conf.SMTP.MaxRecipients
s.AllowInsecureAuth = conf.SMTP.AllowInsecureAuth s.AllowInsecureAuth = conf.SMTP.AllowInsecureAuth
if conf.SMTP.Username == "" && conf.SMTP.Password == "" {
s.AuthDisabled = true
}
if conf.SMTP.Debug { if conf.SMTP.Debug {
s.Debug = os.Stdout s.Debug = os.Stdout
} }