[#75] added option to test s3 connection and send test emails

This commit is contained in:
Gani Georgiev
2022-08-21 14:30:36 +03:00
parent 3f4f4cf031
commit 587cfc335c
49 changed files with 1539 additions and 838 deletions
+1 -1
View File
@@ -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
}
+2 -2
View File
@@ -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
}
// ---
+7 -3
View File
@@ -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)