Closed JensRantil closed 4 years ago
Oh, I just discovered that https://godoc.org/github.com/jordan-wright/email#Email.AttachFile and https://godoc.org/github.com/jordan-wright/email#Email.Attach returns their newly created *Attachment
s. I still think those functions shouldn't be bundled with the Email
type, but in the spirit of remaining backwards compatible, I will then only add the boolean.
This would be really useful to merge this PR. I'm currently developing https://github.com/slurdge/goeland and I need to use multipart/related to include a header picture for the emails. Is there anything that block the merging ?
Merged. Thanks @JensRantil!
I am coding up an HTML e-mail where I'd like to present attached images with the HTML and I don't want the images to presented as attachments to the e-mail. From what I understand the way to do this is to bundle the
text/html
part inside amultipart/related
part. Themultipart/related
then also contains the images.I've been googling a fair amount for some Golang library that could help with me with this to no avail. As such, I'm willing to contribute this functionality to this library. https://stackoverflow.com/a/53798744 explains what needs to be done.
The open question is how, API-wise, to signal that an attachment should be related to the
text/html
part and not be part of the MIME root (as it always is today). I see two alternatives:htmlRelated bool
to theAttachment
type. Important that it defaults tofalse
to keep backwards compatibility.HTMLAttachments []*Attachment
(ormap[ContentID]*Attachment
forContent-ID
uniqueness) field to theEmail
type.Note, that both alternatives will require the user to manually modifying field(s) on https://godoc.org/github.com/jordan-wright/email#Email since neither https://godoc.org/github.com/jordan-wright/email#Email.AttachFile nor https://godoc.org/github.com/jordan-wright/email#Email.Attach have parameters allowing a user to specify that it's an HTML attachment. If HTML attachment should be a first-hand feature, I'd vote to deprecate/remove https://godoc.org/github.com/jordan-wright/email#Email.AttachFile and https://godoc.org/github.com/jordan-wright/email#Email.Attach and instead make them builder functions to construct
*Attachment
instances which then can be additionally modified and/or added to the correct field on https://godoc.org/github.com/jordan-wright/email#Email.Thoughts? I vote for the non-backwards compatible change above together with adding
htmlRelated bool
toAttachment
.