Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppError ¶
type AppError string
AppError represents application-level errors.
const (
ErrInvalidConfig AppError = "invalid app config"
)
Application-level errors
type Email ¶
type Email struct { Recipients []string // Email recipients Subject string // Email subject Body string // Email body TemplateFileName string // Template file name Data map[string]interface{} // Data for template parsing }
Email contains email data.
If data is provided, the template will be parsed with it. Otherwise, it will be parsed with the struct below.
struct { Title string; Body string }
type EmailAuthConfig ¶
type EmailAuthConfig struct { Host string // Email provider's host Port int // Email provider's port Username string // Email provider's username Password string // Email provider's password From string // Sender's email address }
EmailAuthConfig contains email authentication data.
Example:
EmailAuthConfig{Host: "smtp.gmail.com", Port: 587, Username: "user", Password: "password", From: "me@gmail.com"}
type EmailError ¶
type EmailError string
EmailError represents email-related errors.
const (
ErrEmptyTo EmailError = "email recipient(s) is empty"
)
Email errors
func (EmailError) Error ¶
func (e EmailError) Error() string
type Mailer ¶
type Mailer interface { Validate(kind ValidateKind) error SendEmail(mail *Email) error }
func NewMailer ¶
func NewMailer(auth EmailAuthConfig, templateDir string) Mailer
type MailerConfig ¶
type MailerConfig struct { Config EmailAuthConfig TemplateDir string // contains filtered or unexported fields }
MailerConfig holds email sending configuration.
func (*MailerConfig) SendEmail ¶
func (g *MailerConfig) SendEmail(mail *Email) error
SendEmail sends an email to the specified recipients with the given subject, template, and data.
func (*MailerConfig) Validate ¶
func (g *MailerConfig) Validate(kind ValidateKind) error
Validate validates the email data.
type ValidateKind ¶
type ValidateKind string
Click to show internal directories.
Click to hide internal directories.