go-gomail / gomail

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

Attachments using readers #38

Closed mcuadros closed 8 years ago

mcuadros commented 8 years ago

This PRs adds an alternative method of attach or embed files in Message using a io.Reader allowing to attach files made on the fly and without needing to save a file to disk.

alexcesaro commented 8 years ago

Thank you but it is already possible using SetCopyFunc:

var r io.Reader // Your reader
m.Attach("foo.txt", gomail.SetCopyFunc(func(w io.Writer) error {
    _, err := io.Copy(w, r)
    return err
}))
mcuadros commented 8 years ago

Oh great! Thanks