use gabriel-vasile/mimetype for the mail attachments

This commit is contained in:
Gani Georgiev
2025-03-18 00:50:35 +02:00
parent 824c7db388
commit 9f1946057f
4 changed files with 108 additions and 2 deletions

View File

@@ -116,12 +116,20 @@ func (c *SMTPClient) send(m *Message) error {
// add regular attachements (if any)
for name, data := range m.Attachments {
yak.Attach(name, data)
r, mime, err := detectReaderMimeType(data)
if err != nil {
return err
}
yak.AttachWithMimeType(name, r, mime)
}
// add inline attachments (if any)
for name, data := range m.InlineAttachments {
yak.AttachInline(name, data)
r, mime, err := detectReaderMimeType(data)
if err != nil {
return err
}
yak.AttachInlineWithMimeType(name, r, mime)
}
// add custom headers (if any)