[#275] added support to customize the default user email templates from the Admin UI
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user