email

package
v1.42.52 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Content     string `json:"content,omitempty"`
	Type        string `json:"type,omitempty"`
	Name        string `json:"name,omitempty"`
	Filename    string `json:"filename,omitempty"`
	Disposition string `json:"disposition,omitempty"`
	ContentID   string `json:"contentId,omitempty"`
}

Attachment holds attachement information

type Email

type Email struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address"`
}

Email name and address for sender, recpient, etc

type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Custom header

type List

type List struct {
	// External ID of email list
	Id string `json:"id"`

	// Provider integration ID
	ProviderId string `json:"providerId,omitempty"`

	// Respect double-optin or not
	DoubleOptin bool `json:"doubleOptin"`

	// Whether to update existing contacts
	UpdateExisting bool `json:"updateExisting"`

	// Whether to replace interests
	ReplaceInterests bool `json:"replaceInterests"`

	// Whether this list is enabled or not
	Enabled bool `json:"enabled"`
}

Mailchimp configuration

type Marketer

type Marketer interface {
	Subscribe(l *List, s *Subscriber) error
}

type Message

type Message struct {
	Subject          string                            `json:"subject,omitempty"`
	From             Email                             `json:"from"`
	ReplyTo          Email                             `json:"replyTo,omitempty"`
	To               []Email                           `json:"to"`
	CC               []Email                           `json:"cc,omitempty"`
	BCC              []Email                           `json:"bcc,omitempty"`
	HTML             string                            `json:"html,omitempty"`
	Text             string                            `json:"text,omitempty"`
	TemplateData     map[string]map[string]interface{} `json:"templateData,omitempty"`
	TemplateID       string                            `json:"templateId,omitempty"`
	Attachments      []Attachment                      `json:"attachments,omitempty"`
	Substitutions    Substitutions                     `json:"substitutions,omitempty"`
	Personalizations Personalizations                  `json:"personalizations,omitempty"`
	Headers          []Header                          `json:"headers,omitempty"`
	SendAt           time.Time                         `json:"sendAt,omitempty"`
	Tags             []string                          `json:"tags,omitempty"`
	Tracking         Tracking                          `json:"tracking,omitempty"`
}

Represents a single email message

func NewMessage

func NewMessage() *Message

func (*Message) AddAttachments

func (m *Message) AddAttachments(ats ...Attachment)

func (*Message) AddBCCs

func (m *Message) AddBCCs(bccs ...Email)

func (*Message) AddCCs

func (m *Message) AddCCs(ccs ...Email)

func (*Message) AddPersonalizations

func (m *Message) AddPersonalizations(personalizations Personalizations)

func (*Message) AddSubsitutions

func (m *Message) AddSubsitutions(subs Substitutions)

func (*Message) AddTos

func (m *Message) AddTos(tos ...Email)

type Personalization

type Personalization struct {
	// Override default message
	Substitutions Substitutions `json:"substitution"`
	Subject       string        `json:"subject,omitempty"`
	Headers       []Header      `json:"headers,omitempty"`
	SendAt        time.Time     `json:"sendAt,omitempty"`
}

Tags to replace in an email for a specific recipient

func NewPersonalization

func NewPersonalization() *Personalization

type Personalizations

type Personalizations map[string]*Personalization

Map of address -> personalizations

type Sender

type Sender interface {
	Send(message *Message) error
}

type Setting

type Setting struct {
	Enabled    bool    `json:"enabled"`
	From       Email   `json:"from"`
	ReplyTo    Email   `json:"replyTo"`
	Subject    string  `json:"subject"`
	CC         []Email `json:"cc,omitempty"`
	BCC        []Email `json:"bcc,omitempty"`
	HTML       string  `json:"html,omitempty" datastore:",noindex"`
	Text       string  `json:"text,omitempty" datastore:",noindex"`
	TemplateId string  `json:"templateId,omitempty"`
	ProviderId string  `json:"providerId"`
}

type Settings

type Settings struct {
	// Global enable/disable of email
	Enabled bool `json:"enabled"`

	// Defaults for all email settings
	Defaults struct {
		From       Email   `json:"from"`
		ReplyTo    Email   `json:"replyTo"`
		CC         []Email `json:"cc,omitempty"`
		BCC        []Email `json:"bcc,omitempty"`
		ProviderId string  `json:"providerId"`
	} `json:"defaults"`

	// Per-email configuration
	Affiliate struct {
		Welcome Setting `json:"welcome"`
	} `json:"affiliate"`

	Order struct {
		Confirmation  Setting `json:"confirmation"`
		Refund        Setting `json:"refund"`
		RefundPartial Setting `json:"refundPartial"`
		Shipped       Setting `json:"shipped"`
		Updated       Setting `json:"updated"`
	} `json:"order"`

	User struct {
		Welcome         Setting `json:"welcome"`
		ConfirmEmail    Setting `json:"confirmEmail"`
		Activated       Setting `json:"activated"`
		ResetPassword   Setting `json:"resetPassword"`
		PasswordUpdated Setting `json:"updatePassword"`
	} `json:"user"`

	Subscriber struct {
		Welcome Setting `json:"welcome"`
	} `json:"subscriber"`
}

System-wide email settings

func (Settings) Get

func (s Settings) Get(typ Type) Setting

Return email settings updated from defaults

type Subscriber

type Subscriber struct {
	FirstName string   `json:"firstName"`
	LastName  string   `json:"lastName"`
	Email     Email    `json:"email"`
	Metadata  Map      `json:"metadata"`
	Tags      []string `json:"tags"`
}

func (Subscriber) Md5

func (s Subscriber) Md5() string

type Substitutions

type Substitutions map[string]string

Map of substiutitons to apply to email on provider side

type Tracking

type Tracking struct {
	Opens  bool `json:"opens"`
	Clicks bool `json:"clicks"`
}

Tracking settings for a given message

type Type

type Type string

Types of system-defined emails

const (
	AffiliateWelcome    Type = "affiliate.welcome"
	OrderConfirmation   Type = "order.confirmation"
	OrderRefund         Type = "order.refund"
	OrderRefundPartial  Type = "order.refund-partial"
	OrderShipped        Type = "order.shipped"
	OrderUpdated        Type = "order.updated"
	ReferralSignup      Type = "referral.signup"
	SubscriberWelcome   Type = "subscriber.welcome"
	UserActivated       Type = "user.activated"
	UserConfirmEmail    Type = "user.confirmemail"
	UserPasswordUpdated Type = "user.passwordUpdated"
	UserResetPassword   Type = "user.resetPassword"
	UserUpdated         Type = "user.updated"
	UserWelcome         Type = "user.welcome"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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