From 9a420d26e16e8a6ffb527c981d7e991ffb4b6898 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Thu, 29 Apr 2021 16:54:01 +0200 Subject: [PATCH] use html email body by default, add alternative text only body --- internal/common/email.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/common/email.go b/internal/common/email.go index 5233701..7f43311 100644 --- a/internal/common/email.go +++ b/internal/common/email.go @@ -44,7 +44,7 @@ type MailAttachment struct { } // SendEmailWithAttachments sends a mail with optional attachments. -func SendEmailWithAttachments(cfg MailConfig, sender, replyTo, subject, body string, htmlBody string, receivers []string, attachments []MailAttachment) error { +func SendEmailWithAttachments(cfg MailConfig, sender, replyTo, subject, body, htmlBody string, receivers []string, attachments []MailAttachment) error { srv := mail.NewSMTPClient() srv.Host = cfg.Host @@ -89,10 +89,8 @@ func SendEmailWithAttachments(cfg MailConfig, sender, replyTo, subject, body str SetReplyTo(replyTo). SetSubject(subject) - email.SetBody(mail.TextPlain, body) - if htmlBody != "" { - email.SetBody(mail.TextHTML, htmlBody) - } + email.SetBody(mail.TextHTML, htmlBody) + email.AddAlternative(mail.TextPlain, body) for _, attachment := range attachments { attachmentData, err := ioutil.ReadAll(attachment.Data)