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

Use ContentID if provided to lookup attachments #103

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
type File struct {
// FilePath is the path of the file to attach.
FilePath string
// ContentID is the contentID of the attachment. Optional. Used instead of Name to look up inline attachment in the body if provided.
ContentID string
// Name is the name of file in attachment. Required for Data and B64Data. Optional for FilePath.
Name string
// MimeType of attachment. If empty then is obtained from Name (if not empty) or FilePath. If cannot obtained, application/octet-stream is set.
Expand Down
6 changes: 5 additions & 1 deletion message.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ func (msg *message) addFiles(files []*File, inline bool) {
header.Set("Content-Transfer-Encoding", encoding.string())
if inline {
header.Set("Content-Disposition", "inline;\n \tfilename=\""+encodeHeader(escapeQuotes(file.Name), msg.charset, 10)+`"`)
header.Set("Content-ID", "<"+msg.getCID(file.Name)+">")
if len(file.ContentID) > 0 {
header.Set("Content-ID", "<"+msg.getCID(file.ContentID)+">")
} else {
header.Set("Content-ID", "<"+msg.getCID(file.Name)+">")
}
} else {
header.Set("Content-Disposition", "attachment;\n \tfilename=\""+encodeHeader(escapeQuotes(file.Name), msg.charset, 10)+`"`)
}
Expand Down
Loading