Alerting: Add EmbeddedContents as alternative embedding in smtp (#99937)

Adds support for embedding []byte in SmtpClient instead of filenames. This is backwards compatible as it uses a new field EmbeddedContents to add an alternative to the existing EmbeddedFiles which takes filenames.
This commit is contained in:
Matthew Jacobson
2025-02-05 11:12:30 -05:00
committed by GitHub
parent 0ca1febb77
commit a93664ff3d
6 changed files with 77 additions and 35 deletions
+7
View File
@@ -142,6 +142,13 @@ func (sc *SmtpClient) setFiles(
m.Embed(file)
}
for _, file := range msg.EmbeddedContents {
m.Embed(file.Name, gomail.SetCopyFunc(func(writer io.Writer) error {
_, err := writer.Write(file.Content)
return err
}))
}
for _, file := range msg.AttachedFiles {
file := file
m.Attach(file.Name, gomail.SetCopyFunc(func(writer io.Writer) error {