email

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package email defines the EmailSender interface and built-in implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoginAlertData

type LoginAlertData struct {
	FirstName    string
	IPAddress    string
	DeviceInfo   string
	Time         string
	AppName      string
	SupportEmail string
}

LoginAlertData is injected into the login alert email template.

type PasswordResetData

type PasswordResetData struct {
	FirstName    string
	ResetURL     string
	Token        string // raw token for API-only consumers
	ExpiresIn    string
	IPAddress    string // IP that requested the reset
	AppName      string
	SupportEmail string
}

PasswordResetData is injected into the password reset email template.

type SMTPConfig

type SMTPConfig struct {
	Host         string
	Port         int
	Username     string
	Password     string
	FromAddress  string
	FromName     string
	TemplatesDir string // optional: path to custom templates directory
}

SMTPConfig holds the configuration for the SMTP sender.

type SMTPSender

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

SMTPSender sends real emails via SMTP using gomail. Import gopkg.in/gomail.v2 in your application to use this.

func NewSMTPSender

func NewSMTPSender(cfg SMTPConfig) (*SMTPSender, error)

NewSMTPSender creates an SMTPSender, loading templates from disk or embedded defaults.

func (*SMTPSender) SendLoginAlert

func (s *SMTPSender) SendLoginAlert(to string, data LoginAlertData) error

func (*SMTPSender) SendPasswordReset

func (s *SMTPSender) SendPasswordReset(to string, data PasswordResetData) error

func (*SMTPSender) SendVerification

func (s *SMTPSender) SendVerification(to string, data VerificationData) error

type Sender

type Sender interface {
	SendVerification(to string, data VerificationData) error
	SendPasswordReset(to string, data PasswordResetData) error
	SendLoginAlert(to string, data LoginAlertData) error
}

Sender is the interface chiauth uses to send auth emails. Implement this interface to use any email provider (Resend, SendGrid, etc.).

type StdoutSender

type StdoutSender struct{}

StdoutSender prints email content to stdout instead of sending real emails. This is the default when no EmailSender is configured. Perfect for backend-only developers using Postman.

func (*StdoutSender) SendLoginAlert

func (s *StdoutSender) SendLoginAlert(to string, data LoginAlertData) error

func (*StdoutSender) SendPasswordReset

func (s *StdoutSender) SendPasswordReset(to string, data PasswordResetData) error

func (*StdoutSender) SendVerification

func (s *StdoutSender) SendVerification(to string, data VerificationData) error

type VerificationData

type VerificationData struct {
	FirstName       string
	VerificationURL string // full URL with token
	Token           string // raw token — for API-only (Postman) consumers
	ExpiresIn       string // e.g. "24 hours"
	AppName         string
	SupportEmail    string
}

VerificationData is injected into the verification email template.

Jump to

Keyboard shortcuts

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