mailer

package
v0.0.0-...-963cf5d Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderGeneric

func RenderGeneric(data GenericContactData) (string, error)

RenderGeneric renders the notification mail of a generic contact form.

func ValidAddress

func ValidAddress(s string) bool

ValidAddress reports whether s is a single plain email address that SendMessage accepts.

Types

type ContactFormData

type ContactFormData struct {
	Name     string
	Email    string
	Richtung string
	Anliegen string
	Warum    string
	Format   string
	Preise   string
	Wunsch   string
	IP       string
	Time     time.Time
}

ContactFormData holds all fields from the contact form.

type ContactMailer

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

func NewContactMailer

func NewContactMailer(cfg config.SMTPConfig) *ContactMailer

NewContactMailer creates a new mailer using the site's SMTP config.

func (*ContactMailer) Send

func (m *ContactMailer) Send(data ContactFormData) error

Send sends a nicely formatted HTML email with the contact request.

func (*ContactMailer) SendGeneric

func (m *ContactMailer) SendGeneric(data GenericContactData) error

SendGeneric sends a nicely formatted HTML email for a generic, config-driven contact form. Mirrors Send() above but is field-schema-agnostic.

func (*ContactMailer) SendMessage

func (m *ContactMailer) SendMessage(msg Message) error

SendMessage sends msg to msg.To. Unlike SendGeneric (which always goes to the site's own From address) the recipient is arbitrary, so To and ReplyTo must be plain addresses: anything that could inject headers is rejected.

type GenericContactData

type GenericContactData struct {
	Subject  string
	SiteName string
	Domain   string // site domain (derived from base_url) — used for SMTP HELO and the email footer
	Fields   []GenericFormField
	IP       string
	Time     time.Time
}

GenericContactData holds a fully config-driven contact form submission, used by sites that declare a Contact{} block in app.sml (see internal/config) instead of the legacy hardcoded wieder-leben field set above.

type GenericFormField

type GenericFormField struct {
	Label string
	Value string
}

GenericFormField is one label/value row rendered into a generic contact-form email.

type Message

type Message struct {
	To      string // recipient address
	ReplyTo string // optional
	Subject string
	HTML    string
	Text    string // optional plain text alternative (multipart/alternative)
	// Unsubscribe is an https URL for List-Unsubscribe; it also announces
	// RFC 8058 one-click unsubscribe (a POST to the same URL).
	Unsubscribe string
	Domain      string // site domain, used for the SMTP HELO name
}

Message is a ready-rendered HTML email to one recipient.

Jump to

Keyboard shortcuts

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