added mailer.Message.InlineAttachments field

This commit is contained in:
Gani Georgiev
2024-12-13 20:27:04 +02:00
parent 2b2dafaf88
commit 239daf2023
5 changed files with 4822 additions and 4813 deletions
+10 -9
View File
@@ -9,15 +9,16 @@ import (
// Message defines a generic email message struct.
type Message struct {
From mail.Address `json:"from"`
To []mail.Address `json:"to"`
Bcc []mail.Address `json:"bcc"`
Cc []mail.Address `json:"cc"`
Subject string `json:"subject"`
HTML string `json:"html"`
Text string `json:"text"`
Headers map[string]string `json:"headers"`
Attachments map[string]io.Reader `json:"attachments"`
From mail.Address `json:"from"`
To []mail.Address `json:"to"`
Bcc []mail.Address `json:"bcc"`
Cc []mail.Address `json:"cc"`
Subject string `json:"subject"`
HTML string `json:"html"`
Text string `json:"text"`
Headers map[string]string `json:"headers"`
Attachments map[string]io.Reader `json:"attachments"`
InlineAttachments map[string]io.Reader `json:"inlineAttachments"`
}
// Mailer defines a base mail client interface.
+6 -1
View File
@@ -114,11 +114,16 @@ func (c *SMTPClient) send(m *Message) error {
yak.Cc(addressesToStrings(m.Cc, true)...)
}
// add attachements (if any)
// add regular attachements (if any)
for name, data := range m.Attachments {
yak.Attach(name, data)
}
// add inline attachments (if any)
for name, data := range m.InlineAttachments {
yak.AttachInline(name, data)
}
// add custom headers (if any)
var hasMessageId bool
for k, v := range m.Headers {