Documentation
¶
Overview ¶
Package mailit provides a simple interface that depends on gomail-v2 (https://github.com/go-gomail/gomail) to compose emails and to mail them efficiently without writing complex code.
More info on Github: https://github.com/wisdommatt/mailit
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mailer ¶
type Mailer interface {
TextMailer
TemplateMailer
}
Mailer is the interface that wraps TextMailer and TemplateMailer.
func NewMailer ¶
func NewMailer(config SMTPConfig) Mailer
NewMailer returns a new mailer which implements the Mailer interface.
NewMailer uses the informations in config to prefill the SMTP configurations for the mail.
type SMTPConfig ¶
SMTPConfig holds smtp configurations that a required to send the mail.
type TemplateDependencies ¶
type TemplateDependencies struct {
// From is the email address of the sender
// e.g no-reply@example.com
From string
// To is the receiver/receivers of the email
// e.g []{"user@example.com", "user2@example.com"}.
To []string
// SenderName is the name fo the email sender.
SenderName string
// Subject is the subject of the email e.g Hello NewsLetter
Subject string
// ContentType is the content type of the template e.g
// text/plain or text/html etc
ContentType string
// Template is the directory location of the template
// e.g templates/welcome.html, templates/hello.txt
Template string
// TemplateData is the data/content you want to pass to the
// template e.g User Info, Order Details etc
TemplateData interface{}
// Attachments should hold the list of attachments to send with
// the email if there is any.
// []{"assets/docs/welcome.pdf", "assets/images/admin.jpeg"}
Attachments []string
}
TemplateDependencies is the struct that holds dependencies for a template based email. e.g template directory, sender/receiver email etc.
type TemplateMailer ¶
type TemplateMailer interface {
SendTemplate(dep TemplateDependencies) error
}
TemplateMailer is the interface that wraps SendTemplate method.
type TextDependencies ¶
type TextDependencies struct {
// From is the email address of the sender
// e.g no-reply@example.com
From string
// SenderName is the name fo the email sender.
SenderName string
// To is the receiver/receivers of the email
// e.g []{"user@example.com", "user2@example.com"}.
To []string
// Subject is the subject of the email e.g Hello NewsLetter
Subject string
// Body is the body of the email e.g Thanks for signing up
Body string
// Attachments should hold the list of attachments to send with
// the email if there is any.
// []{"assets/docs/welcome.pdf", "assets/images/admin.jpeg"}
Attachments []string
}
TextDependencies is the struct that holds dependencies for a plain text email. e.g message body, sender/receiver email etc.
type TextMailer ¶
type TextMailer interface {
SendText(dep TextDependencies) error
}
TextMailer is the interface that wraps SendText method.