Skip to content

Commit

Permalink
Attachment header: add "name=" in addition to the classical "filename…
Browse files Browse the repository at this point in the history
…=" (#81)
  • Loading branch information
AdrienUfferte committed Apr 17, 2023
1 parent 87b7a70 commit 0dbf4f5
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 88 deletions.
6 changes: 3 additions & 3 deletions attachments.go
Expand Up @@ -112,7 +112,7 @@ func (m *MailYak) writeAttachments(mixed partCreator, splitter writeWrapper) err
item.mimeType = http.DetectContentType(h[:hLen])
}

ctype := fmt.Sprintf("%s;\n\tfilename=%q", item.mimeType, item.filename)
ctype := fmt.Sprintf("%s;\n\tfilename=%q; name=%q", item.mimeType, item.filename, item.filename)

part, err := mixed.CreatePart(getMIMEHeader(item, ctype))
if err != nil {
Expand Down Expand Up @@ -145,15 +145,15 @@ func getMIMEHeader(a attachment, ctype string) textproto.MIMEHeader {

cid := fmt.Sprintf("<%s>", a.filename)
if a.inline {
disp = fmt.Sprintf("inline;\n\tfilename=%q", a.filename)
disp = fmt.Sprintf("inline;\n\tfilename=%q; name=%q", a.filename, a.filename)
header = textproto.MIMEHeader{
"Content-Type": {ctype},
"Content-Disposition": {disp},
"Content-Transfer-Encoding": {"base64"},
"Content-ID": {cid},
}
} else {
disp = fmt.Sprintf("attachment;\n\tfilename=%q", a.filename)
disp = fmt.Sprintf("attachment;\n\tfilename=%q; name=%q", a.filename, a.filename)
header = textproto.MIMEHeader{
"Content-Type": {ctype},
"Content-Disposition": {disp},
Expand Down

0 comments on commit 0dbf4f5

Please sign in to comment.