However, this is very much limited to attachments from filesystem, not allowing other attachment content providers.
It would be useful, if it would be possible to add an attachment from:
io.Reader, which pretty much standard in golang, or
io.ReadCloser, which would provide shorter way for io.Readers sources, which need close (no need to make own defer,..), and any io.Reader can be converted to io.ReadCloser using ioutil.NopCloser,... or
[]byte, which allows pretty much any attachment content source, but requires more work for callers.
Personally, I would prefer io.ReadCloser, which (in combination with ioutil.NopCloser) would create a versatile API covering the most of the use-cases.
gomail provides function to add attachment using filename:
However, this is very much limited to attachments from filesystem, not allowing other attachment content providers.
It would be useful, if it would be possible to add an attachment from:
io.Reader
, which pretty much standard in golang, orio.ReadCloser
, which would provide shorter way forio.Reader
s sources, which need close (no need to make own defer,..), and anyio.Reader
can be converted toio.ReadCloser
usingioutil.NopCloser
,... or[]byte
, which allows pretty much any attachment content source, but requires more work for callers.Personally, I would prefer
io.ReadCloser
, which (in combination withioutil.NopCloser
) would create a versatile API covering the most of the use-cases.