Documentation
¶
Index ¶
- Variables
- func Send(publicKey, privateKey, sender string, recipients []string, subject, msg string) error
- type HTMLEmailer
- type Kind
- type Lookup
- type MailjetNotifier
- func (n *MailjetNotifier) Recipients(skey int64, kind Kind) ([]string, time.Duration, error)
- func (n *MailjetNotifier) Send(ctx context.Context, skey int64, kind Kind, msg string) error
- func (n *MailjetNotifier) SendHTMLEmail(ctx context.Context, subject string, templatePath string, data interface{}) error
- type Notifier
- type Option
- func WithFilter(filter string) Option
- func WithPeriod(period time.Duration) Option
- func WithRecipient(recipient string) Option
- func WithRecipientLookup(lookup Lookup) Option
- func WithRecipients(recipients []string) Option
- func WithSecrets(secrets map[string]string) Option
- func WithSender(sender string) Option
- func WithStore(store TimeStore) Option
- type TimeStore
Constants ¶
This section is empty.
Variables ¶
var ErrNoRecipient = errors.New("no recipient")
Errors.
Functions ¶
Types ¶
type HTMLEmailer ¶ added in v0.0.4
type HTMLEmailer interface { // SendHTMLEmail sends a formatted HTML email. SendHTMLEmail(ctx context.Context, subject string, templatePath string) error }
HTMLEmailer is an interface for types which are able to send formatted emails using HTML.
type Lookup ¶ added in v0.0.4
Lookup is a function that returns the recipients and their corresponding notification period for a given site and notification kind. It is used with WithRecipientLookup.
type MailjetNotifier ¶ added in v0.0.4
type MailjetNotifier struct {
// contains filtered or unexported fields
}
Notifier represents a notifier that uses the Mailjet API to send email.
func NewMailjetNotifier ¶ added in v0.0.4
func NewMailjetNotifier(options ...Option) (*MailjetNotifier, error)
NewMailjetNotifier initializes a MailjetNotifier with the supplied options. See WithSender, WithRecipient, WithFilter, WithStore and WithSecrets for a description of the various options. Secrets are required to send actual emails using the Mailjet API, but can be omitted during testing.
func (*MailjetNotifier) Recipients ¶ added in v0.0.4
Recipients returns a list of recipients and their corresponding minimum notification period for the given site and notification kind. It uses the WithRecipientLookup function if supplied, else defaults to the recipients supplied by either WithRecipient or WithRecipients and the period supplied by WithPeriod. ErrNoRecipient is returned if there are no recipients.
func (*MailjetNotifier) Send ¶ added in v0.0.4
Send sends an email message, depending on what options are present. With filters, then all filters must match in order to send. With persistence, then the message is sent only if it was not sent to the same recipient recently.
func (*MailjetNotifier) SendHTMLEmail ¶ added in v0.0.4
func (n *MailjetNotifier) SendHTMLEmail(ctx context.Context, subject string, templatePath string, data interface{}) error
SendHTMLEmail sends a formatted HTML email using the MailJet API.
type Option ¶ added in v0.0.4
type Option func(*MailjetNotifier) error
Option is a functional option supplied to Init.
func WithFilter ¶ added in v0.0.4
WithFilter applies a filter string. If multiple WithFilter options are applied, they form a compound conjunctive filter. Specifiying an empty filter string clears the filter.
func WithPeriod ¶ added in v0.0.4
WithPeriod sets the minimum notification period, which is used in conjunction with a TimeStore.
func WithRecipient ¶ added in v0.0.4
WithRecipient sets a single recipient email address.
func WithRecipientLookup ¶ added in v0.0.4
WithRecipientLookup sets a function to look up multiple recipients and their corresponding notification period given a site key and a notification kind.
func WithRecipients ¶ added in v0.0.4
WithRecipients sets multiple recipient email addresses.
func WithSecrets ¶ added in v0.0.4
WithSecrets applies the secrets necessary for sending email, notably the public and private mail API keys. This is always required, unless testing.
func WithSender ¶ added in v0.0.4
WithSender sets the sender email address.