email

package
v0.52.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 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
	PreButton  template.HTML
	ButtonText string
	ButtonLink string
	PostButton template.HTML
}

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) SendInformational added in v0.48.0

func (c *Client) SendInformational(opts *Informational) error

func (*Client) SendInvoicePaymentFailed added in v0.50.0

func (c *Client) SendInvoicePaymentFailed(opts *InvoicePaymentFailed) error

func (*Client) SendInvoicePaymentSuccess added in v0.50.0

func (c *Client) SendInvoicePaymentSuccess(opts *InvoicePaymentSuccess) error

SendInvoicePaymentSuccess Currently Used only when a previously failed invoice payment succeeds

func (*Client) SendInvoiceUnpaid added in v0.50.0

func (c *Client) SendInvoiceUnpaid(opts *InvoiceUnpaid) error

SendInvoiceUnpaid sent after the payment grace period has ended

func (*Client) SendOrganizationAddition

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

func (*Client) SendOrganizationInvite

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

func (*Client) SendPlanUpdate added in v0.51.0

func (c *Client) SendPlanUpdate(opts *PlanUpdate) error

func (*Client) SendProjectAccessGranted added in v0.48.0

func (c *Client) SendProjectAccessGranted(opts *ProjectAccessGranted) error

func (*Client) SendProjectAccessRejected added in v0.48.0

func (c *Client) SendProjectAccessRejected(opts *ProjectAccessRejected) error

func (*Client) SendProjectAccessRequest added in v0.48.0

func (c *Client) SendProjectAccessRequest(opts *ProjectAccessRequest) 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

func (*Client) SendSubscriptionCancelled added in v0.51.0

func (c *Client) SendSubscriptionCancelled(opts *SubscriptionCancelled) error

func (*Client) SendSubscriptionEnded added in v0.50.0

func (c *Client) SendSubscriptionEnded(opts *SubscriptionEnded) error

func (*Client) SendSubscriptionRenewed added in v0.51.0

func (c *Client) SendSubscriptionRenewed(opts *SubscriptionRenewed) error

func (*Client) SendTeamPlanRenewal added in v0.51.1

func (c *Client) SendTeamPlanRenewal(opts *TeamPlan) error

SendTeamPlanRenewal sends customised plan renewed email for Team Plan

func (*Client) SendTeamPlanStarted added in v0.51.1

func (c *Client) SendTeamPlanStarted(opts *TeamPlan) error

SendTeamPlanStarted sends customised plan started email for Team Plan

func (*Client) SendTrialEnded added in v0.50.0

func (c *Client) SendTrialEnded(opts *TrialEnded) error

func (*Client) SendTrialEndingSoon added in v0.50.0

func (c *Client) SendTrialEndingSoon(opts *TrialEndingSoon) error

func (*Client) SendTrialExtended added in v0.51.0

func (c *Client) SendTrialExtended(opts *TrialExtended) error

func (*Client) SendTrialGracePeriodEnded added in v0.50.0

func (c *Client) SendTrialGracePeriodEnded(opts *TrialGracePeriodEnded) error

func (*Client) SendTrialStarted added in v0.50.0

func (c *Client) SendTrialStarted(opts *TrialStarted) error

func (*Client) SendWelcomeToTeam added in v0.51.1

func (c *Client) SendWelcomeToTeam(opts *Welcome) error

func (*Client) SendWelcomeToTrial added in v0.51.1

func (c *Client) SendWelcomeToTrial(opts *Welcome) error

type Informational added in v0.48.0

type Informational struct {
	ToEmail string
	ToName  string
	Subject string
	Body    template.HTML
}

type InvoicePaymentFailed added in v0.50.0

type InvoicePaymentFailed struct {
	ToEmail            string
	ToName             string
	OrgName            string
	Currency           string
	Amount             string
	PaymentURL         string
	GracePeriodEndDate time.Time
}

type InvoicePaymentSuccess added in v0.50.0

type InvoicePaymentSuccess struct {
	ToEmail        string
	ToName         string
	OrgName        string
	PaymentDate    time.Time
	BillingPageURL string
}

type InvoiceUnpaid added in v0.50.0

type InvoiceUnpaid struct {
	ToEmail    string
	ToName     string
	OrgName    string
	PaymentURL string
}

type OrganizationAddition

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

type OrganizationInvite

type OrganizationInvite struct {
	ToEmail       string
	ToName        string
	AcceptURL     string
	OrgName       string
	RoleName      string
	InvitedByName string
}

type PlanUpdate added in v0.51.0

type PlanUpdate struct {
	ToEmail  string
	ToName   string
	OrgName  string
	PlanName string
}

type ProjectAccessGranted added in v0.48.0

type ProjectAccessGranted struct {
	ToEmail     string
	ToName      string
	OpenURL     string
	OrgName     string
	ProjectName string
}

type ProjectAccessRejected added in v0.48.0

type ProjectAccessRejected struct {
	ToEmail     string
	ToName      string
	OrgName     string
	ProjectName string
}

type ProjectAccessRequest added in v0.48.0

type ProjectAccessRequest struct {
	Title       string
	Body        template.HTML
	ToEmail     string
	ToName      string
	Email       string
	OrgName     string
	ProjectName string
	ApproveLink string
	DenyLink    string
}

type ProjectAddition

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

type ProjectInvite

type ProjectInvite struct {
	ToEmail       string
	ToName        string
	AcceptURL     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
	DisplayName    string
	ReportTime     time.Time
	DownloadFormat string
	OpenLink       string
	DownloadLink   string
	EditLink       string
	External       bool
}

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 SubscriptionCancelled added in v0.51.0

type SubscriptionCancelled struct {
	ToEmail    string
	ToName     string
	OrgName    string
	PlanName   string
	BillingURL string
	EndDate    time.Time
}

type SubscriptionEnded added in v0.50.0

type SubscriptionEnded struct {
	ToEmail    string
	ToName     string
	OrgName    string
	BillingURL string
}

type SubscriptionRenewed added in v0.51.0

type SubscriptionRenewed struct {
	ToEmail  string
	ToName   string
	OrgName  string
	PlanName string
}

type TeamPlan added in v0.51.1

type TeamPlan struct {
	ToEmail          string
	ToName           string
	OrgName          string
	FrontendURL      string
	PlanName         string
	BillingStartDate time.Time
}

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

type TrialEnded added in v0.50.0

type TrialEnded struct {
	ToEmail            string
	ToName             string
	OrgName            string
	UpgradeURL         string
	GracePeriodEndDate time.Time
}

type TrialEndingSoon added in v0.50.0

type TrialEndingSoon struct {
	ToEmail      string
	ToName       string
	OrgName      string
	UpgradeURL   string
	TrialEndDate time.Time
}

type TrialExtended added in v0.51.0

type TrialExtended struct {
	ToEmail      string
	ToName       string
	OrgName      string
	TrialEndDate time.Time
}

type TrialGracePeriodEnded added in v0.50.0

type TrialGracePeriodEnded struct {
	ToEmail    string
	ToName     string
	OrgName    string
	UpgradeURL string
}

type TrialStarted added in v0.50.0

type TrialStarted struct {
	ToEmail      string
	ToName       string
	OrgName      string
	FrontendURL  string
	TrialEndDate time.Time
}

type Welcome added in v0.51.1

type Welcome struct {
	ToEmail     string
	ToName      string
	Subject     string
	FrontendURL string
	WelcomeText template.HTML
}

Jump to

Keyboard shortcuts

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