go-gomail / gomail

The best way to send emails in Go.
MIT License
4.32k stars 572 forks source link

Embedding a lot of images #87

Closed suntong closed 7 years ago

suntong commented 7 years ago

Can gomail supports embedding a lot of images?

From https://godoc.org/gopkg.in/gomail.v2#Message.Embed

it seems that gomail only support embedding one image.
To embed a lot of them, there are still lots of extra manual works to make it works, i.e., you have to specify where shall those emails appear, both in the Text portion and the HTML portion. But all these can be dealt with programmatically, to free people from such tedious manual work.

I'm proposing,

func (m *Message) Embed(filename ...string) string string

the two string returns are Text and HTML content for such embeds the images. For e.g., for single image,

Text: image1.jpg
HTML: <img src="cid:image1.jpg" alt="image1" />

so on and so forth.

Would that be OK? If I submit a patch, would it be accepted?

suntong commented 7 years ago

Hmm, if backward compatibility is paramount, then I can add a new function, say Embeding that takes the above form.

suntong commented 7 years ago

Better not to do that at the lib side, but client side instead, because gomail has to be used programmatically anyway.