diff --git a/cmd/fake-smtp/smtp.go b/cmd/fake-smtp/smtp.go index 2963f0e..509dacc 100644 --- a/cmd/fake-smtp/smtp.go +++ b/cmd/fake-smtp/smtp.go @@ -43,7 +43,9 @@ func (b *Backend) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session, err 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. @@ -105,6 +107,11 @@ func startSMTPServer(conf *config.Config, ctn *service.Container) { s.MaxMessageBytes = conf.SMTP.MaxMessageBytes s.MaxRecipients = conf.SMTP.MaxRecipients s.AllowInsecureAuth = conf.SMTP.AllowInsecureAuth + + if conf.SMTP.Username == "" && conf.SMTP.Password == "" { + s.AuthDisabled = true + } + if conf.SMTP.Debug { s.Debug = os.Stdout }