Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidEmail = errors.New("invalid email address")
ErrInvalidEmail indicates an email address is not valid.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address string
Address is how househunt represents email addresses.
func ParseAddress ¶
ParseAddress parses the given string and checks if it's shaped like an email address. It returns an error if the input is not a valid email address. Note that this doesn't guarantee the email address actually exists, it only checks the format.
func (*Address) UnmarshalText ¶
type LogSender ¶
type LogSender struct {
// contains filtered or unexported fields
}
LogSender is a Sender that logs the email to the logger instead of sending it. Note that this is not meant for production use as it logs the email addresses and all email contents. Resulting in sensitive information being logged.
func NewLogSender ¶
NewLogSender creates a new LogSender.
type MemorySender ¶
type MemorySender struct { Emails []struct { From Address Recipient Address Subject string Body string } }
func NewMemorySender ¶
func NewMemorySender() *MemorySender
type Renderer ¶
type Renderer interface {
Render(w io.Writer, name string, element TemplateElement, data any) error
}
Renderer is responsible for rendering email templates.
type Sender ¶
type Sender interface {
Send(ctx context.Context, from, recipient Address, subject, body string) error
}
Sender is responsible for actually sending an email.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides the main functionality for sending emails.
func NewService ¶
func NewService(renderer Renderer, sender Sender, cfg ServiceConfig) *Service
type ServiceConfig ¶
ServiceConfig is the configuration for the email service.
type TemplateElement ¶
type TemplateElement string
TemplateElement is used by a renderer to identify the different parts of an email template.
const ( ElementSubject TemplateElement = "subject" ElementBody TemplateElement = "body" )