parent
de623e612d
commit
6805982221
|
@ -126,8 +126,12 @@ func (w *messageWriter) addFiles(files []*File, isAttachment bool) {
|
||||||
h["Content-Disposition"] = []string{"attachment; filename=\"" + f.Name + "\""}
|
h["Content-Disposition"] = []string{"attachment; filename=\"" + f.Name + "\""}
|
||||||
} else {
|
} else {
|
||||||
h["Content-Disposition"] = []string{"inline; filename=\"" + f.Name + "\""}
|
h["Content-Disposition"] = []string{"inline; filename=\"" + f.Name + "\""}
|
||||||
|
if f.ContentID != "" {
|
||||||
|
h["Content-ID"] = []string{"<" + f.ContentID + ">"}
|
||||||
|
} else {
|
||||||
h["Content-ID"] = []string{"<" + f.Name + ">"}
|
h["Content-ID"] = []string{"<" + f.Name + ">"}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
w.write(h, f.Content, Base64)
|
w.write(h, f.Content, Base64)
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,6 +211,7 @@ type File struct {
|
||||||
Name string
|
Name string
|
||||||
MimeType string
|
MimeType string
|
||||||
Content []byte
|
Content []byte
|
||||||
|
ContentID string
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenFile opens a file on disk to create a gomail.File.
|
// OpenFile opens a file on disk to create a gomail.File.
|
||||||
|
|
|
@ -336,7 +336,9 @@ func TestEmbedded(t *testing.T) {
|
||||||
msg := NewMessage()
|
msg := NewMessage()
|
||||||
msg.SetHeader("From", "from@example.com")
|
msg.SetHeader("From", "from@example.com")
|
||||||
msg.SetHeader("To", "to@example.com")
|
msg.SetHeader("To", "to@example.com")
|
||||||
msg.Embed(CreateFile("image1.jpg", []byte("Content 1")))
|
f := CreateFile("image1.jpg", []byte("Content 1"))
|
||||||
|
f.ContentID = "test-content-id"
|
||||||
|
msg.Embed(f)
|
||||||
msg.Embed(CreateFile("image2.jpg", []byte("Content 2")))
|
msg.Embed(CreateFile("image2.jpg", []byte("Content 2")))
|
||||||
msg.SetBody("text/plain", "Test")
|
msg.SetBody("text/plain", "Test")
|
||||||
|
|
||||||
|
@ -355,7 +357,7 @@ func TestEmbedded(t *testing.T) {
|
||||||
"--_BOUNDARY_1_\r\n" +
|
"--_BOUNDARY_1_\r\n" +
|
||||||
"Content-Type: image/jpeg; name=\"image1.jpg\"\r\n" +
|
"Content-Type: image/jpeg; name=\"image1.jpg\"\r\n" +
|
||||||
"Content-Disposition: inline; filename=\"image1.jpg\"\r\n" +
|
"Content-Disposition: inline; filename=\"image1.jpg\"\r\n" +
|
||||||
"Content-ID: <image1.jpg>\r\n" +
|
"Content-ID: <test-content-id>\r\n" +
|
||||||
"Content-Transfer-Encoding: base64\r\n" +
|
"Content-Transfer-Encoding: base64\r\n" +
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
base64.StdEncoding.EncodeToString([]byte("Content 1")) + "\r\n" +
|
base64.StdEncoding.EncodeToString([]byte("Content 1")) + "\r\n" +
|
||||||
|
|
Loading…
Reference in New Issue