mirror of
https://github.com/h44z/wg-portal
synced 2025-02-26 05:49:14 +00:00
use html email body by default, add alternative text only body
This commit is contained in:
parent
19e6fa2a1a
commit
9a420d26e1
@ -44,7 +44,7 @@ type MailAttachment struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendEmailWithAttachments sends a mail with optional attachments.
|
// 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 := mail.NewSMTPClient()
|
||||||
|
|
||||||
srv.Host = cfg.Host
|
srv.Host = cfg.Host
|
||||||
@ -89,10 +89,8 @@ func SendEmailWithAttachments(cfg MailConfig, sender, replyTo, subject, body str
|
|||||||
SetReplyTo(replyTo).
|
SetReplyTo(replyTo).
|
||||||
SetSubject(subject)
|
SetSubject(subject)
|
||||||
|
|
||||||
email.SetBody(mail.TextPlain, body)
|
email.SetBody(mail.TextHTML, htmlBody)
|
||||||
if htmlBody != "" {
|
email.AddAlternative(mail.TextPlain, body)
|
||||||
email.SetBody(mail.TextHTML, htmlBody)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, attachment := range attachments {
|
for _, attachment := range attachments {
|
||||||
attachmentData, err := ioutil.ReadAll(attachment.Data)
|
attachmentData, err := ioutil.ReadAll(attachment.Data)
|
||||||
|
Loading…
Reference in New Issue
Block a user