Documentation ¶
Index ¶
- Variables
- func Render(name string, data interface{}) (text, html string, err error)
- type Config
- func (c Config) NewInviteAcceptedEmail(r Recipient, i InviteTemplateData) (*newman.EmailMessage, error)
- func (c Config) NewInviteEmail(r Recipient, i InviteTemplateData, token string) (*newman.EmailMessage, error)
- func (c Config) NewPasswordResetRequestEmail(r Recipient, token string) (*newman.EmailMessage, error)
- func (c Config) NewPasswordResetSuccessEmail(r Recipient) (*newman.EmailMessage, error)
- func (c Config) NewSubscriberEmail(r Recipient, organizationName, token string) (*newman.EmailMessage, error)
- func (c Config) NewVerifyEmail(r Recipient, token string) (*newman.EmailMessage, error)
- func (c Config) NewWelcomeEmail(r Recipient, org string) (*newman.EmailMessage, error)
- type EmailData
- type InviteData
- type InviteTemplateData
- type MissingRequiredFieldError
- type Option
- func WithCompanyAddress(address string) Option
- func WithCompanyName(name string) Option
- func WithCorporation(corp string) Option
- func WithDocsDomain(domain string) Option
- func WithFromEmail(email string) Option
- func WithInviteURL(url string) Option
- func WithLogoURL(url string) Option
- func WithProductDomain(domain string) Option
- func WithResetURL(url string) Option
- func WithRootDomain(domain string) Option
- func WithSupportEmail(email string) Option
- func WithVerifySubscriberURL(url string) Option
- func WithVerifyURL(url string) Option
- type Recipient
- type ResetRequestData
- type ResetSuccessData
- type SubscriberEmailData
- type URLConfig
- type VerifyEmailData
- type WelcomeData
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingTemplate is returned when an email template is missing from the template directory ErrMissingTemplate = errors.New("missing email template") )
Functions ¶
Types ¶
type Config ¶
type Config struct { // CompanyName is the name of the company that is sending the email CompanyName string `koanf:"companyName" json:"companyName" default:""` // CompanyAddress is the address of the company that is sending the email, included in the footer CompanyAddress string `koanf:"companyAddress" json:"companyAddress" default:""` // Corporation is the official corporation name that is sending the email, included in the footer Corporation string `koanf:"corporation" json:"corporation" default:""` // FromEmail is the email address that the email is sent from FromEmail string `koanf:"fromEmail" json:"fromEmail" default:""` // SupportEmail is the email address that the recipient can contact for support SupportEmail string `koanf:"supportEmail" json:"supportEmail" default:""` // LogoURL is the URL to the company logo that is included in the email if provided LogoURL string `koanf:"logoURL" json:"logoURL" default:""` // URLS includes URLs that are used in the email templates URLS URLConfig `koanf:"urls" json:"urls"` }
Config includes fields that are common to all the email builders that are configurable
func (Config) NewInviteAcceptedEmail ¶
func (c Config) NewInviteAcceptedEmail(r Recipient, i InviteTemplateData) (*newman.EmailMessage, error)
NewInviteEmail returns a new email message based on the config values and the provided recipient and invite data
func (Config) NewInviteEmail ¶
func (c Config) NewInviteEmail(r Recipient, i InviteTemplateData, token string) (*newman.EmailMessage, error)
NewInviteEmail returns a new email message based on the config values and the provided recipient and invite data
func (Config) NewPasswordResetRequestEmail ¶
func (c Config) NewPasswordResetRequestEmail(r Recipient, token string) (*newman.EmailMessage, error)
NewPasswordResetRequestEmail returns a new email message based on the config values and the provided recipient and token
func (Config) NewPasswordResetSuccessEmail ¶
func (c Config) NewPasswordResetSuccessEmail(r Recipient) (*newman.EmailMessage, error)
NewPasswordResetSuccessEmail returns a new email message based on the config values and the provided recipient
func (Config) NewSubscriberEmail ¶
func (c Config) NewSubscriberEmail(r Recipient, organizationName, token string) (*newman.EmailMessage, error)
NewSubscriberEmail returns a new email message based on the config values and the provided recipient, organization name, and token
func (Config) NewVerifyEmail ¶
NewVerifyEmail returns a new email message based on the config values and the provided recipient and token
func (Config) NewWelcomeEmail ¶
NewWelcomeEmail returns a new email message based on the config values and the provided recipient and organization name
type EmailData ¶
type EmailData struct { Config // Subject is the subject line of the email Subject string `json:"subject"` // Recipient is the person who will receive the email Recipient Recipient `json:"recipient"` }
EmailData includes data fields that are common to all the email builders
type InviteData ¶
type InviteData struct { EmailData // InviterName is the name of the person who is inviting the recipient InviterName string `json:"inviter_name"` // OrganizationName is the name of the organization that the user is being invited to OrganizationName string `json:"organization_name"` // Role is the role that the user is being invited to join the organization as Role string `json:"role"` }
InviteData includes fields for the invite email
type InviteTemplateData ¶
InviteTemplateData includes the data needed to render the invite email templates
type MissingRequiredFieldError ¶
type MissingRequiredFieldError struct { // RequiredField that is missing RequiredField string }
MissingRequiredFieldError is returned when a required field was not provided in a request
func (*MissingRequiredFieldError) Error ¶
func (e *MissingRequiredFieldError) Error() string
Error returns the MissingRequiredFieldError in string format
type Option ¶
type Option func(*Config)
Option is a function that sets a field on an EmailMessage
func WithCompanyAddress ¶
WithCompanyAddress sets company address for the footer of the email
func WithCompanyName ¶
WithCompanyName sets the company name for the email
func WithCorporation ¶
WithCorporation sets the corporation used in the footer of the email
func WithDocsDomain ¶
WithDocsDomain sets the docs domain for the email
func WithFromEmail ¶
WithFromEmail sets the from email for the email
func WithInviteURL ¶
WithInviteURL sets the invite URL for the email
func WithLogoURL ¶
WithLogoURL sets the logo URL for the email, this field is optional and omitted from the email if not provided
func WithProductDomain ¶
WithProductDomain sets the product domain for the email
func WithResetURL ¶
WithResetURL sets the reset URL for the email
func WithRootDomain ¶
WithRootDomain sets the root domain for the email
func WithSupportEmail ¶
WithSupportEmail sets the support email for the email
func WithVerifySubscriberURL ¶
WithVerifySubscriberURL sets the verify subscriber URL for the email
func WithVerifyURL ¶
WithVerifyURL sets the verify URL for the email
type Recipient ¶
type Recipient struct { // Email is the email address of the recipient Email string `json:"email"` // FirstName is the first name of the recipient FirstName string `json:"first_name"` // LastName is the last name of the recipient LastName string `json:"last_name"` }
Recipient includes fields for the recipient of the email
type ResetRequestData ¶
type ResetRequestData struct {
EmailData
}
ResetRequestData includes fields for the password reset request email
type ResetSuccessData ¶
type ResetSuccessData struct {
EmailData
}
ResetSuccessData includes fields for the password reset success email
type SubscriberEmailData ¶
type SubscriberEmailData struct { EmailData // Organization is the name of the organization that the user is subscribing to OrganizationName string `json:"organization_name"` }
SubscriberEmailData includes fields for the subscriber email
type URLConfig ¶
type URLConfig struct { // Root is the root domain for the email Root string `koanf:"root" json:"root" default:""` // Product is the product domain for the email, usually the main UI where a user logs in Product string `koanf:"product" json:"product" default:""` // Docs is the docs domain for the email, where a user can find documentation Docs string `koanf:"docs" json:"docs" default:""` // Verify is the URL to verify an email address Verify string `koanf:"verify" json:"verify" default:""` // Invite is the URL to accept an invite to an organization Invite string `koanf:"invite" json:"invite" default:""` // PasswordReset is the URL to reset a password PasswordReset string `koanf:"reset" json:"reset" default:""` // VerifySubscriber is the URL to verify a subscriber for an organization VerifySubscriber string `koanf:"verifySubscriber" json:"verifySubscriber" default:""` }
URLConfig includes urls that are used in the email templates
type VerifyEmailData ¶
type VerifyEmailData struct {
EmailData
}
VerifyEmailData includes fields for the verify email
type WelcomeData ¶
type WelcomeData struct { EmailData // Organization is the name of the organization that the user is joining Organization string `json:"organization"` }
WelcomeData includes fields for the welcome email