Closed martinrode closed 3 years ago
Hey there!
Could you please provide a sample email that I can use to reproduce the issue?
Hi Jordan,
simply set HTML, Attachment (HTMLRelated), and no Text.
The logic in „Bytes“ set isMixed and isAlternative both to false and later when adding the html attachment the subWriter is nil.
I dont know enough about email, but I assume the isMixed or isAlternative need to be turned on in this case where the mail requires an HTML body and an attachment.
If you need code, I can provide this on Monday when I am back in the office.
Best, Martin
Since i stumbled upon the same bug here something to reproduce:
// *Mailer contains the pool and some config stuff
func (m *Mailer) Send(e *email.Email) error {
d := struct {
Text string
}{
Text: "whatever" ,
}
// the template references the image via cid
temp, err := m.parseTemplate("my_template.html", d)
if err != nil {
return err
}
e := email.NewEmail()
e.HTML = temp
e.From = "no-reply@foo.bar"
e.Subject = "Blarb"
e.To = []string{"foo@bar.baz"}
dir, _ := os.Getwd()
a, _ := e.AttachFile(dir+"/mailer/logo.png")
// set to multipart to embed image
a.HTMLRelated = true
// text needs to be set to something non empty for multipart attachments to work
// uncommenting this line will cause the crash
// e.Text = []byte(" ")
return m.pool.Send(e, m.timeout)
}