email

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package email allows sending transactional and marketing emails via Sendgrid. It's designed to use templ to create HTML emails.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMailSettings

func NewMailSettings() *mail.MailSettings

func NewTrackingSettings

func NewTrackingSettings() *mail.TrackingSettings

Types

type Content

type Content struct {
	ToName    string
	ToEmail   string
	Subject   string
	HTML      Renderer
	PlainText string
}

type MarketingClient

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

MarketingClient handles marketing emails with unsubscribe functionality

func NewMarketingClient

func NewMarketingClient(apiKey string, fromName, fromAddr string, unsubGroups []int) *MarketingClient

NewMarketingClient creates a new client for sending compliant marketing emails. apiKey is the Sendgrid API key. fromName and fromAddr are the display name and email address that will appear in the From field. unsubGroups is a list of Sendgrid unsubscribe group IDs that this client is allowed to use. compliancePlainTxt is the plain text compliance footer that will be appended to all marketing emails. renderer is used to wrap email content in a standard layout with headers, footers, etc.

func (MarketingClient) EnableSandbox

func (c MarketingClient) EnableSandbox()

func (*MarketingClient) Send

func (c *MarketingClient) Send(ctx context.Context, content Content, unsubGroup int, opts ...Option) error

Send sends a marketing email with unsubscribe links and footer

type Option

type Option func(*option)

Option is a function type that modifies the baseClient

func WithMailSettings

func WithMailSettings(settings *mail.MailSettings) Option

WithMailSettings sets custom mail settings Overrides all settings (does not merge with defaults)

func WithTrackingSettings

func WithTrackingSettings(settings *mail.TrackingSettings) Option

WithTrackingSettings sets custom tracking settings Overrides all settings (does not merge with defaults)

type Renderer

type Renderer interface {
	// Render renders HTML to the writer
	Render(ctx context.Context, w io.Writer) error
}

type TransactionalClient

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

TransactionalClient handles transactional emails like account verification, password reset, etc.

func NewTransactionalClient

func NewTransactionalClient(apiKey string, fromName, fromAddr string) *TransactionalClient

NewTransactionalClient creates a new client for sending transactional emails

func (*TransactionalClient) EnableSandbox

func (c *TransactionalClient) EnableSandbox()

func (*TransactionalClient) Send

func (c *TransactionalClient) Send(ctx context.Context, content Content, opts ...Option) error

Send sends a transactional email (like account verification, password reset, etc.) These emails don't have unsubscribe links.

Jump to

Keyboard shortcuts

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