Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attachment API #4

Closed
kron4eg opened this issue Oct 27, 2014 · 1 comment
Closed

Attachment API #4

kron4eg opened this issue Oct 27, 2014 · 1 comment
Milestone

Comments

@kron4eg
Copy link

kron4eg commented Oct 27, 2014

I have the feeling that those signatures should have io.Reader instead of *File

func OpenFile(filename string) (*File, error)
func (msg *Message) Attach(f ...*File)
func (msg *Message) Embed(image ...*File)

And using ioutil.ReadFile (inside CreateFile()) will dump whole file contents right into memory...Which is not very good for performance and in general.

@alexcesaro
Copy link
Member

Until very recently Gomail used smtp.SendMail from the standard library to send emails and that function takes msg []byte as an argument. So the whole email needed to be in memory anyway.

Now that Gomail use a custom function to send emails, the email could be streamed to the SMTP server. So it is true that the content field of File could now be an io.Reader instead of []byte.

However doing that change will break backward compatibility because the signatures of File, OpenFile, CreateFile and SetSendMail will have to be updated.

Since this is not a big issue (email attachments are supposed to be relatively small) I will wait for other breaking changes before fixing this issue and bumping the version number.

@alexcesaro alexcesaro added this to the v2 milestone Oct 27, 2014
alexcesaro added a commit that referenced this issue Jul 14, 2015
The File can now be streamed to the SMTP server directly without
being buffered into memory first.

Fixes #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants