email

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidEmail

func IsValidEmail(email string) bool

IsValidEmail performs email validation using RFC 5322 parsing

func MaskEmail

func MaskEmail(email string) string

MaskEmail masks an email address for logging (e.g., "user@example.com" -> "u***@example.com")

Types

type Config

type Config struct {
	Enabled            bool
	Host               string
	Port               int
	Username           string
	Password           string
	From               string // format: "Display Name <email>" or just "email"
	TLS                bool   // implicit TLS (port 465)
	StartTLS           bool   // STARTTLS upgrade (port 587)
	InsecureSkipVerify bool   // skip certificate verification
	LoginAuth          bool   // use LOGIN auth instead of PLAIN
	Timeout            time.Duration
	Template           string   // path to custom template file (optional)
	Branding           string   // application name for email footer
	BrandingURL        string   // link URL for branding in email footer
	Notifier           Notifier // optional, for testing; if nil, creates default SMTP notifier
}

Config contains SMTP configuration

type Notifier

type Notifier interface {
	Send(ctx context.Context, destination, text string) error
}

Notifier defines the interface for sending email notifications

type Request

type Request struct {
	To       string // recipient email address
	Subject  string // email subject
	FromName string // display name for From header
	Link     string // the secret link to include in email body
}

Request contains all parameters for sending an email

type Sender

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

Sender sends emails with secret links using go-pkgz/notify

func NewSender

func NewSender(cfg Config) (*Sender, error)

NewSender creates a new email sender with the given configuration

func (*Sender) GetDefaultFromName

func (s *Sender) GetDefaultFromName() string

GetDefaultFromName returns the cached default from name

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, req Request) error

Send sends an email with the secret link

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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