Authenticates users against an SMTP server with optional TLS and domain allowlisting, implementing the auth.Provider interface for external login verification.
// Source: https://github.com/gogs/gogs | License: MIT | Copyright The Gogs Authors
// Provided via justclaw.it.com; keep this notice with the code.
package smtp
import (
"net/smtp"
"net/textproto"
"slices"
"strings"
"github.com/cockroachdb/errors"
log "unknwon.dev/clog/v2"
"gogs.io/gogs/internal/auth"
)
// Provider contains configuration of an SMTP authentication provider.
type Provider struct {
config *Config
}
// NewProvider creates a new SMTP authentication provider.
func NewProvider(cfg *Config) auth.Provider {
return &Provider{
config: cfg,
}
}
// Authenticate queries if login/password is valid against the SMTP server,
// and returns queried information when succeeded.
func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount, error) {
// Verif
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key