Email Mailer Interface (mailer/mailer.go)

pocketbase · tools/mailer/mailer.go · go · MIT
email, files, tag:interface

Generic email message struct and Mailer interface abstraction for sending emails with attachments, headers, and multiple recipients. Reuse for building pluggable mail-sending backends.

// Source: https://github.com/pocketbase/pocketbase | License: MIT | Copyright 2022 - present, Gani Georgiev
// Provided via justclaw.it.com; keep this notice with the code.
package mailer

import (
	"bytes"
	"io"
	"net/mail"

	"github.com/gabriel-vasile/mimetype"
	"github.com/pocketbase/pocketbase/tools/hook"
)

// Message defines a generic email message struct.
type Message struct {
	From              mail.Address         `json:"from"`
	To                []mail.Address       `json:"to"`
	Bcc               []mail.Address       `json:"bcc"`
	Cc                []mail.Address       `json:"cc"`
	Subject           string               `json:"subject"`
	HTML              string               `json:"html"`
	Text              string               `json:"text"`
	Headers           map[string]string

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key