email

package
v3.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package email verifies email ownership and sends one-time codes over SMTP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verified added in v3.1.0

func Verified(cfg *config.EmailConfig, providerVerified, localVerified bool) bool

Verified reports whether an upstream email is verified enough for the configured verification mode. providerVerified is the provider's email_verified assertion; localVerified reports whether the same connector account previously verified the email with a one-time code. When it returns false, sign-in must send a one-time code or deny the user, and refresh revokes the grant. A nil cfg, from an omitted email block, uses the default mode.

Types

type Credentials

type Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Credentials contains SMTP authentication credentials.

func ParseCredentials

func ParseCredentials(raw string) (Credentials, error)

ParseCredentials parses and validates JSON-encoded SMTP credentials.

type OTPMailer

type OTPMailer struct {
	// contains filtered or unexported fields
}

OTPMailer renders and sends one-time verification code messages.

func NewOTPMailer

func NewOTPMailer(mailer *SMTPMailer, templates *templates.Manager, ttl time.Duration) *OTPMailer

NewOTPMailer creates an SMTP-backed one-time code mailer.

func (*OTPMailer) SendOTP

func (m *OTPMailer) SendOTP(ctx context.Context, to, code string, expiresAt time.Time) error

SendOTP renders and sends an OTP message with its exact expiry to an email address.

type SMTPMailer

type SMTPMailer struct {
	// contains filtered or unexported fields
}

SMTPMailer sends multipart messages over SMTP.

func NewSMTPMailer

func NewSMTPMailer(config config.SMTPConfig, credentials Credentials) *SMTPMailer

NewSMTPMailer creates an SMTP transport.

type Sender

type Sender interface {
	SendOTP(ctx context.Context, to, code string, expiresAt time.Time) error
}

Sender sends the application email messages supported by Truster.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL