Documentation
¶
Overview ¶
Purpose: This file implements the GoMail email sending component. It provides an interface and implementation for sending rich text and HTML emails via SMTP.
Philosophy: Email sending is a core utility for user communication (verification, reset, notifications). We provide a production-ready, pure standard library implementation based on `net/smtp`. This adheres to our zero-dependency framework core while providing a clean, ergonomic API that handles all low-level SMTP formatting and handshakes.
Architecture: The mailer exposes a `Mailer` struct which is initialized with `Config`. The global `gostack.Mail` facade allows easy application-wide usage. The mail component defines a `Message` representing SMTP metadata and payload (To, CC, Subject, Body, HTML).
Choice: We chose a direct `net/smtp.SendMail` wrapper because it is fast, simple, and is part of the Go stdlib. By wrapping it, we support standard auth types (like Plain Auth) and structure the headers/body automatically to avoid common issues with MIME formatting.
Implementation: - Config: holds SMTP server information (Host, Port, Username, Password, FromAddress, FromName). - Message: represents the details of an email to be sent. - Mailer: holds config and provides Send() method. - Send(msg Message): translates Message into raw RFC 822 format, establishes connection, authenticates, and sends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Host string
Port int
Username string
Password string
FromAddress string
FromName string
}
Config defines the configuration properties required to connect to an SMTP server.