[#75] added option to test s3 connection and send test emails
This commit is contained in:
@@ -12,7 +12,7 @@ type Mailer interface {
|
||||
fromEmail mail.Address,
|
||||
toEmail mail.Address,
|
||||
subject string,
|
||||
htmlBody string,
|
||||
htmlContent string,
|
||||
attachments map[string]io.Reader,
|
||||
) error
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func (m *Sendmail) Send(
|
||||
fromEmail mail.Address,
|
||||
toEmail mail.Address,
|
||||
subject string,
|
||||
htmlBody string,
|
||||
htmlContent string,
|
||||
attachments map[string]io.Reader,
|
||||
) error {
|
||||
headers := make(http.Header)
|
||||
@@ -50,7 +50,7 @@ func (m *Sendmail) Send(
|
||||
if _, err := buffer.Write([]byte("\r\n")); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := buffer.Write([]byte(htmlBody)); err != nil {
|
||||
if _, err := buffer.Write([]byte(htmlContent)); err != nil {
|
||||
return err
|
||||
}
|
||||
// ---
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"net/mail"
|
||||
"net/smtp"
|
||||
"strings"
|
||||
|
||||
"github.com/domodwyer/mailyak/v3"
|
||||
)
|
||||
@@ -43,7 +44,7 @@ func (m *SmtpClient) Send(
|
||||
fromEmail mail.Address,
|
||||
toEmail mail.Address,
|
||||
subject string,
|
||||
htmlBody string,
|
||||
htmlContent string,
|
||||
attachments map[string]io.Reader,
|
||||
) error {
|
||||
smtpAuth := smtp.PlainAuth("", m.username, m.password, m.host)
|
||||
@@ -64,9 +65,12 @@ func (m *SmtpClient) Send(
|
||||
yak.FromName(fromEmail.Name)
|
||||
}
|
||||
yak.From(fromEmail.Address)
|
||||
yak.To(toEmail.Address)
|
||||
|
||||
// wrap in brackets as workaround for spamassasin "TO_NO_BRKTS_HTML_ONLY" rule
|
||||
yak.To(strings.TrimSpace(fmt.Sprintf("%s <%s>", toEmail.Name, toEmail.Address)))
|
||||
|
||||
yak.Subject(subject)
|
||||
yak.HTML().Set(htmlBody)
|
||||
yak.HTML().Set(htmlContent)
|
||||
|
||||
for name, data := range attachments {
|
||||
yak.Attach(name, data)
|
||||
|
||||
Reference in New Issue
Block a user