func (email *Email) SetEmailConfig(host string, port int, username string, password string, from string, to []string) {
	email.rw.Lock()
	defer email.rw.Unlock()
	email.host = host
	email.port = port
	email.username = username
	email.password = password
	email.from = from
	email.to = to
	email.formatter = email.formatFunc(email)
}
SetEmailConfig allows updating of the email config in flight and is thread safe.
package email
import (
	"bytes"
	"html/template"
	"sync"
	gomail "gopkg.in/gomail.v2"
	"github.com/go-playground/log/v7"
)
type FormatFunc func(email *Email) Formatter
type Formatter func(e log.Entry) *gomail.Message
const (
	contentType     = "text/html"
	defaultTemplate = `<!DOCTYPE html>
<html>
    <body>
        <h2>{{ .Message }}</h2>
        <p>{{ .Level.String }}</p>
        <p>{{ ts . }}</p>
        {{ range $f := .Fields }}
            <p><b>{{ $f.Key }}</b>: {{ $f.Value }}</p>
        {{ end }}
    </body>
</html>`
)
type Email struct {
	enabled         bool
	formatter       Formatter
	formatFunc      FormatFunc
	timestampFormat string
	template        *template.Template
	host            string
	port            int
	username        string
	password        string
	from            string
	to              []string
	rw              sync.RWMutex
	once            sync.Once
}
func New(host string, port int, username string, password string, from string, to []string) *Email {
	e := &Email{
		enabled:         true,
		timestampFormat: log.DefaultTimeFormat,
		host:            host,
		port:            port,
		username:        username,
		password:        password,
		from:            from,
		to:              to,
		formatFunc:      defaultFormatFunc,
	}
	e.SetTemplate(defaultTemplate)
	return e
}
func (email *Email) SetTemplate(htmlTemplate string) {
	email.rw.Lock()
	defer email.rw.Unlock()
	email.template = template.Must(template.New("email").Funcs(
		template.FuncMap{
			"ts": func(e log.Entry) (ts string) {
				ts = e.Timestamp.Format(email.timestampFormat)
				return
			},
		},
	).Parse(htmlTemplate))
}
func (email *Email) From() string {
	return email.from
}
func (email *Email) To() []string {
	return email.to
}
func (email *Email) Template() *template.Template {
	return email.template
}
func (email *Email) SetTimestampFormat(format string) {
	email.rw.Lock()
	defer email.rw.Unlock()
	email.timestampFormat = format
}
func (email *Email) SetFormatFunc(fn FormatFunc) {
	email.rw.Lock()
	defer email.rw.Unlock()
	email.formatFunc = fn
}