Documentation
¶
Index ¶
- Constants
- Variables
- func AttachJSON(message *mail.SGMailV3, data []byte, filename string) (err error)
- func LoadAttachment(message *mail.SGMailV3, attachmentPath string) (err error)
- func Render(name string, data interface{}) (text, html string, err error)
- func WelcomeEmail(data WelcomeData) (message *mail.SGMailV3, err error)
- type Config
- type EmailData
- type EmailManager
- type SendGridClient
- type WelcomeData
Constants ¶
const ( UnknownDate = "unknown date" DateFormat = "Monday, January 2, 2006" )
const (
WelcomeRE = "Welcome to Ensign"
)
Email subject lines
Variables ¶
Functions ¶
func AttachJSON ¶ added in v0.4.0
AttachJSON by marshaling the specified data into human-readable data and encode and attach it to the email as a file.
func LoadAttachment ¶ added in v0.4.0
LoadAttachment onto email from a file on disk.
func Render ¶ added in v0.4.0
Render returns the text and html executed templates for the specified name and data. Ensure that the extension is not supplied to the render method.
func WelcomeEmail ¶ added in v0.4.0
func WelcomeEmail(data WelcomeData) (message *mail.SGMailV3, err error)
WelcomeEmail creates a welcome email for a new user
Types ¶
type Config ¶
type Config struct {
APIKey string `split_words:"true" required:"false"`
FromEmail string `split_words:"true" default:"ensign@rotational.io"`
AdminEmail string `split_words:"true" default:"admins@rotational.io"`
EnsignListID string `split_words:"true" required:"false"`
Testing bool `split_words:"true" default:"false"`
Archive string `split_words:"true"`
}
Configures SendGrid for sending emails and managing marketing contacts.
type EmailData ¶ added in v0.4.0
EmailData includes data fields that are common to all the email builders such as the subject and sender/recipient information.
type EmailManager ¶
type EmailManager struct {
// contains filtered or unexported fields
}
EmailManager allows a server to send rich emails using the SendGrid service.
func New ¶
func New(conf Config) (m *EmailManager, err error)
New email manager with the specified configuration.
func (*EmailManager) AddContact ¶ added in v0.4.0
func (m *EmailManager) AddContact(contact *sg.Contact) error
AddContact adds a contact to the SendGrid marketing contacts list. TODO: Allow the user to specify list IDs using variadic arguments.
type SendGridClient ¶
SendGridClient is an interface that can be implemented by live email clients to send real emails or by mock clients for testing.