From 05d84a80080b1c494761dd830fc284871337f5ef Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 15 Feb 2018 03:02:31 -0500 Subject: Modified advanced mail implementation to properly support multiple attachments with the same file name (#8289) --- utils/mail.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'utils/mail.go') diff --git a/utils/mail.go b/utils/mail.go index 633f97818..9023f7090 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -157,19 +157,18 @@ func sendMail(mimeTo, smtpTo string, from mail.Address, subject, htmlBody string } for _, fileInfo := range attachments { + bytes, err := fileBackend.ReadFile(fileInfo.Path) + if err != nil { + return err + } + m.Attach(fileInfo.Name, gomail.SetCopyFunc(func(writer io.Writer) error { - bytes, err := fileBackend.ReadFile(fileInfo.Path) - if err != nil { - return err - } if _, err := writer.Write(bytes); err != nil { return model.NewAppError("SendMail", "utils.mail.sendMail.attachments.write_error", nil, err.Error(), http.StatusInternalServerError) } return nil })) - } - } conn, err1 := connectToSMTPServer(config) -- cgit v1.2.3-1-g7c22