Skip to content

Commit

Permalink
mail: Adjust attachments content type
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshineplan committed Jul 19, 2023
1 parent 77eea0b commit 614ae01
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions mail/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,15 @@ func (m *Message) Bytes(id string) []byte {
if l := len(m.Attachments); l > 0 {
for i, attachment := range m.Attachments {
w.PrintfLine("--" + boundary)
if mimetype := mime.TypeByExtension(filepath.Ext(attachment.Filename)); mimetype != "" {
w.PrintfLine("Content-Type: " + mimetype)
} else {
w.PrintfLine("Content-Type: application/octet-stream")
}
if attachment.ContentID != "" {
w.PrintfLine("Content-Type: message/rfc822")
w.PrintfLine(`Content-Disposition: inline; filename="=?UTF-8?B?%s?="`, toBase64(attachment.Filename))
w.PrintfLine("Content-ID: <%s>", attachment.ContentID)
} else {
if mimetype := mime.TypeByExtension(filepath.Ext(attachment.Filename)); mimetype != "" {
w.PrintfLine("Content-Type: " + mimetype)
} else {
w.PrintfLine("Content-Type: application/octet-stream")
}
w.PrintfLine(`Content-Disposition: attachment; filename="=?UTF-8?B?%s?="`, toBase64(attachment.Filename))
}
w.PrintfLine("Content-Transfer-Encoding: base64")
Expand Down

0 comments on commit 614ae01

Please sign in to comment.