[#275] added support to customize the default user email templates from the Admin UI

This commit is contained in:
Gani Georgiev
2022-08-14 19:30:45 +03:00
parent 1de56d3d9e
commit 7d10d20de1
47 changed files with 1648 additions and 1188 deletions
-10
View File
@@ -5,18 +5,12 @@ import (
"io"
"net/mail"
"net/smtp"
"regexp"
"strings"
"github.com/domodwyer/mailyak/v3"
"github.com/microcosm-cc/bluemonday"
)
var _ Mailer = (*SmtpClient)(nil)
// regex to select all tabs
var tabsRegex = regexp.MustCompile(`\t+`)
// NewSmtpClient creates new `SmtpClient` with the provided configuration.
func NewSmtpClient(
host string,
@@ -74,10 +68,6 @@ func (m *SmtpClient) Send(
yak.Subject(subject)
yak.HTML().Set(htmlBody)
// set also plain text content
policy := bluemonday.StrictPolicy() // strips all tags
yak.Plain().Set(strings.TrimSpace(tabsRegex.ReplaceAllString(policy.Sanitize(htmlBody), "")))
for name, data := range attachments {
yak.Attach(name, data)
}