go-gomail / gomail

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

Feature Request: io.Reader as attachment #149

Open wshaman opened 4 years ago

wshaman commented 4 years ago

Short: Add io.Reader as attachment Motivation: Using any cloud file storage (s3 in my case) you have to

  1. read stream from storage
  2. save it to file on local disk
  3. add local file as attachment to mail (here gomail reads localfile as stream and converts to []byte)

We can reduce amount of conversions and keep code more straight-forward

ahuret commented 3 years ago

Nice idea, but I think it would be better to reuse the existing (appendFile) so that no dupplication here.

It means changing appendFile signature and filename would be an io.Reader (instead of string), and Attach( method would be responsible for converting filename string to io.Reader by opening the file.

What do you think ? :)

mcbaloo commented 3 years ago

@ahuret I have a file URL on a cloud server I want to attach to a mail. How do I implement this?