email

package
v0.43.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

runtime/pkg/email

This package contains logic and templates for sending transactional emails.

How templating works

We use MJML to generate the email layout HTML. The MJML templates are found in the templates directory.

To inject content into the email layout HTML, we use Go's built-in html/template library.

We currently have just one template:

  • call_to_action.mjml shows a title, body and button

Adding/updating an MJML template

  1. Add or edit the .mjml file in templates (we recommend using the MJML online IDE)
  2. Run ./runtime/pkg/email/templates/generate.sh
  3. Add a util function in email.go for loading and populating the template

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallToAction

type CallToAction struct {
	ToEmail    string
	ToName     string
	Subject    string
	Title      string
	Body       template.HTML
	ButtonText string
	ButtonLink string
}

type Client

type Client struct {
	Sender Sender
	// contains filtered or unexported fields
}

func New

func New(sender Sender) *Client

func (*Client) SendAlertStatus added in v0.41.0

func (c *Client) SendAlertStatus(opts *drivers.AlertStatus) error

func (*Client) SendCallToAction

func (c *Client) SendCallToAction(opts *CallToAction) error

func (*Client) SendOrganizationAddition

func (c *Client) SendOrganizationAddition(opts *OrganizationAddition) error

func (*Client) SendOrganizationInvite

func (c *Client) SendOrganizationInvite(opts *OrganizationInvite) error

func (*Client) SendProjectAddition

func (c *Client) SendProjectAddition(opts *ProjectAddition) error

func (*Client) SendProjectInvite

func (c *Client) SendProjectInvite(opts *ProjectInvite) error

func (*Client) SendScheduledReport

func (c *Client) SendScheduledReport(opts *ScheduledReport) error

type OrganizationAddition

type OrganizationAddition struct {
	ToEmail       string
	ToName        string
	FrontendURL   string
	OrgName       string
	RoleName      string
	InvitedByName string
}

type OrganizationInvite

type OrganizationInvite struct {
	ToEmail       string
	ToName        string
	AdminURL      string
	FrontendURL   string
	OrgName       string
	RoleName      string
	InvitedByName string
}

type ProjectAddition

type ProjectAddition struct {
	ToEmail       string
	ToName        string
	FrontendURL   string
	OrgName       string
	ProjectName   string
	RoleName      string
	InvitedByName string
}

type ProjectInvite

type ProjectInvite struct {
	ToEmail       string
	ToName        string
	AdminURL      string
	FrontendURL   string
	OrgName       string
	ProjectName   string
	RoleName      string
	InvitedByName string
}

type SMTPOptions

type SMTPOptions struct {
	SMTPHost     string
	SMTPPort     int
	SMTPUsername string
	SMTPPassword string
	FromEmail    string
	FromName     string
	BCC          string
}

type ScheduledReport

type ScheduledReport struct {
	ToEmail        string
	ToName         string
	Title          string
	ReportTime     time.Time
	DownloadFormat string
	OpenLink       string
	DownloadLink   string
	EditLink       string
}

type Sender

type Sender interface {
	Send(toEmail, toName, subject, body string) error
}

func NewConsoleSender

func NewConsoleSender(logger *zap.Logger, fromEmail, fromName string) (Sender, error)

func NewNoopSender

func NewNoopSender() Sender

func NewSMTPSender

func NewSMTPSender(opts *SMTPOptions) (Sender, error)

func NewTestSender added in v0.41.0

func NewTestSender() Sender

type TestSender added in v0.41.0

type TestSender struct {
	Emails []struct {
		ToEmail string
		ToName  string
		Subject string
		Body    string
	}
}

func (*TestSender) Send added in v0.41.0

func (s *TestSender) Send(toEmail, toName, subject, body string) error

Jump to

Keyboard shortcuts

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