You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
I needed to use message.Embed() in one email that I was sending with two images.
Currently we can only submit message.Attach().
It was very easy to implement it, but I just wanted some recommendation on the signature of the method, for me the more logical way is to make a breaking change, I just wanted the opinion of Mark before committing my solution.
I wanted to replace
func (m *Message) AddAttachment(name, contentType string, r io.Reader) error
by
func (m *Message) AddAttachment(name string, embedded bool, r io.Reader) error
An other option could be to add a new method AddEmbededAttachament
I propose to remove the contentType string as it is never used in the code (or maybe I'm blind, but guru didn't find any usage except from where we assign it a value).
I also found a bug when we where sending more than one file at the time, with the following code.
I took me a while to debug it, but I saw that inside the returning function it was always the last file that was called with the number of files available. And I remembered then that the returning function where only created at the end of the "mother function" so inside at was always the same value. With this it worked well. So with this small correction it worked well.
func (sm SMTPSender) addAttachments(message Message, gm *gomail.Message) {
for _, at := range message.Attachments {
curAt := at
settings := gomail.SetCopyFunc(func(w io.Writer) error {
_, err := io.Copy(w, curAt.Reader)
return err
})
gm.Attach(curAt.Name, settings)
}
}
The text was updated successfully, but these errors were encountered:
I needed to use message.Embed() in one email that I was sending with two images.
Currently we can only submit message.Attach().
It was very easy to implement it, but I just wanted some recommendation on the signature of the method, for me the more logical way is to make a breaking change, I just wanted the opinion of Mark before committing my solution.
I wanted to replace
func (m *Message) AddAttachment(name, contentType string, r io.Reader) error
by
func (m *Message) AddAttachment(name string, embedded bool, r io.Reader) error
An other option could be to add a new method AddEmbededAttachament
I propose to remove the contentType string as it is never used in the code (or maybe I'm blind, but guru didn't find any usage except from where we assign it a value).
I also found a bug when we where sending more than one file at the time, with the following code.
I took me a while to debug it, but I saw that inside the returning function it was always the last file that was called with the number of files available. And I remembered then that the returning function where only created at the end of the "mother function" so inside at was always the same value. With this it worked well. So with this small correction it worked well.
The text was updated successfully, but these errors were encountered: