email

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SenderNameOpt = "sender_name"
	ReplyToOpt    = "reply_to"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContactInfo

type ContactInfo struct {
	Email string `json:"email"`
	Phone string `json:"phone"`
	Name  string `json:"name"`
}

type EmailClient

type EmailClient interface {
	SendTemplatedEmail(ctx context.Context, recep EmailRecepient, subject string, template Template, o ...EmailOpt) error
	SendHTMLEmail(ctx context.Context, recep EmailRecepient, subject, body string, o ...EmailOpt) error
}

func NewTwilioEmail

func NewTwilioEmail(apiKey string, identity TwilioEmailIdentity) EmailClient

type EmailMetadata

type EmailMetadata struct {
	ReplyTo    *string `json:"reply_to,omitempty"`
	SenderName *string `json:"sender_name,omitempty"`
}

type EmailOpt

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

func WithReplyTo

func WithReplyTo(email string) EmailOpt

func WithSenderName

func WithSenderName(name string) EmailOpt

type EmailRecepient

type EmailRecepient struct {
	// if a name is provided, then it will be used as the display name for the email
	Name string

	// otherwise email will be used as the display name
	Email string
}

type NoopEmailClient

type NoopEmailClient struct {
}

func (*NoopEmailClient) SendHTMLEmail

func (cli *NoopEmailClient) SendHTMLEmail(ctx context.Context, recep EmailRecepient, header, htmlContent string, opts ...EmailOpt) error

func (*NoopEmailClient) SendTemplatedEmail

func (cli *NoopEmailClient) SendTemplatedEmail(ctx context.Context, recep EmailRecepient, subject string, template Template, opts ...EmailOpt) error

type NotificationMetadata

type NotificationMetadata struct {
	Source string `json:"source"`

	// Sender name will show up as the sender of the notification
	EmailMetadata     *EmailMetadata   `json:"email_metadata,omitempty"`
	CreationTimestamp time.Time        `json:"creation_timestamp"`
	DeliveryMethods   []string         `json:"delivery_methods"`
	Type              NotificationType `json:"type"`
}

type NotificationType

type NotificationType string
const (
	Templated NotificationType = "templated"
	Plain     NotificationType = "plain"
)

type PlainNotificationDto

type PlainNotificationDto struct {
	Metadata NotificationMetadata `json:"metadata"`

	Subject     string      `json:"subject"`
	Body        string      `json:"body"`
	ContactInfo ContactInfo `json:"contact_info"`
}

type Template

type Template struct {
	Id   string                 `yaml:"id" json:"id"`
	Data map[string]interface{} `yaml:"data" json:"data"`
}

type TemplatedNotificationDto

type TemplatedNotificationDto struct {
	Metadata NotificationMetadata `json:"metadata"`

	Subject    string `json:"subject"`
	TemplateId string `json:"template_id"`

	// data will be passed into the template engine
	Data map[string]interface{} `json:"data"`

	ContactInfo ContactInfo `json:"contact_info"`
}

type TwilioEmail

type TwilioEmail struct {
	Origin TwilioEmailIdentity
	// contains filtered or unexported fields
}

func (*TwilioEmail) SendHTMLEmail

func (cli *TwilioEmail) SendHTMLEmail(ctx context.Context, recep EmailRecepient, header, htmlContent string, opts ...EmailOpt) error

func (*TwilioEmail) SendTemplatedEmail

func (cli *TwilioEmail) SendTemplatedEmail(
	ctx context.Context,
	recep EmailRecepient,
	subject string,
	template Template,
	opts ...EmailOpt) error

type TwilioEmailIdentity

type TwilioEmailIdentity struct {
	// SenderName is the name that will be used as display name for the email
	SenderName string `yaml:"emailName" json:"emailName"`

	// if SenderName is not provided, then email will be used as the display name
	SenderEmail string `yaml:"email" json:"email"`
}

type TwilioSMSIdentity

type TwilioSMSIdentity struct {
	MessageServiceId string `yaml:"messageServiceId" json:"messageServiceId"`
}

Jump to

Keyboard shortcuts

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