Documentation
¶
Overview ¶
Package mail provides email sending functionality for Omnom notifications.
This package handles SMTP-based email delivery for various application events:
- User login tokens (passwordless authentication)
- Feed update notifications
- System alerts
It supports both HTML and plain text email formats using template-based rendering. Templates are embedded in the application and loaded from the templates/mail directory.
The package maintains a persistent SMTP connection that is reused across multiple sends for efficiency. If the connection is lost, it automatically reconnects. Email sending can be disabled entirely by leaving the SMTP host empty in configuration.
Configuration supports:
- Standard SMTP authentication
- TLS/SSL encryption
- Configurable timeouts
- Custom sender addresses
Example usage:
err := mail.Init(cfg)
if err != nil {
log.Fatal(err)
}
err = mail.Send(
"user@example.com",
"Welcome to Omnom",
"welcome",
map[string]any{"username": "john"},
)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTemplateNotFound is returned when a mail template cannot be found. ErrTemplateNotFound = errors.New("mail template not found") )
Functions ¶
Types ¶
type Templates ¶
Templates holds HTML and text email templates.
func (*Templates) RenderHTML ¶
RenderHTML renders html template with given arguments.