Message.Attach without file
donovansolms opened this issue · 3 comments
Hi,
I have a need to be able to add attachments from memory and not from disk. Is there any way to achieve that currently?
If not, I'm happy to implement an alternative Message.Attach that uses an io.Reader
This is only implemented for the body AFAIK. This would be a useful addition, I think.
Actually, after digging into the package a bit I see it can actually be achieved already using the following:
m.Attach("CustomName.png", mail.SetCopyFunc(func(w io.Writer) error {
_, err = w.Write(fileBytes)
return err
}))
I now understand what #28 was referring to when he said "It's not strictly necessary". I was just seeing 'cannot refer to unexported name mail.file' when trying to use mail.FileSetting.
very close! I was able to receive the email with the attachments but...it's a pdf file with content type text/plain therefore I can't see the content. I'll continue digging.
An example on docs will be very helpful. ( I'll PR as soon as I can get this working )