Documentation
¶
Overview ¶
Package email provides a Mailgun-backed email sender for transactional email delivery. It is intentionally dependency-free beyond the Go standard library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
Attachment describes a file to attach to an email. Data is raw file bytes.
type EmailMessage ¶
type EmailMessage struct {
From string
To []string
CC []string
BCC []string
Subject string
Text string
HTML string
Attachments []Attachment
}
EmailMessage represents an email to be sent.
type MailgunClient ¶
type MailgunClient struct {
// contains filtered or unexported fields
}
MailgunClient sends emails via the Mailgun API.
func NewMailgunClient ¶
func NewMailgunClient(cfg MailgunConfig) *MailgunClient
NewMailgunClient creates a MailgunClient from a MailgunConfig. The returned client uses a dedicated http.Client with a 30-second timeout and connection pooling.
func (*MailgunClient) Send ¶
func (c *MailgunClient) Send(ctx context.Context, msg *EmailMessage) (string, error)
Send posts the email to Mailgun.
type MailgunConfig ¶ added in v0.3.2
type MailgunConfig struct {
Endpoint string `env:"ENDPOINT"`
User string `env:"USER"`
Password string `env:"PASSWORD"`
From string `env:"FROM" envDefault:"noti@doublefin.com"`
}
MailgunConfig holds the configuration for a MailgunClient.
The struct tags follow the caarlos0/env convention so that consumers using that library can parse environment variables with a "MAILGUN_" prefix (e.g. MAILGUN_ENDPOINT, MAILGUN_PASSWORD). The tags themselves do not trigger automatic env-var reading; the caller is responsible for parsing.
func (MailgunConfig) LogValue ¶ added in v0.3.2
func (c MailgunConfig) LogValue() slog.Value
LogValue implements slog.LogValuer, redacting the password.