parent
b4e3113e2d
commit
512e469f62
|
@ -262,7 +262,7 @@ func (msg *Message) Embed(image ...*File) {
|
||||||
if msg.embedded == nil {
|
if msg.embedded == nil {
|
||||||
msg.embedded = image
|
msg.embedded = image
|
||||||
} else {
|
} else {
|
||||||
msg.embedded = append(msg.attachments, image...)
|
msg.embedded = append(msg.embedded, image...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,8 @@ 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("image.jpg", []byte("Content")))
|
msg.Embed(CreateFile("image1.jpg", []byte("Content 1")))
|
||||||
|
msg.Embed(CreateFile("image2.jpg", []byte("Content 2")))
|
||||||
msg.SetBody("text/plain", "Test")
|
msg.SetBody("text/plain", "Test")
|
||||||
|
|
||||||
want := message{
|
want := message{
|
||||||
|
@ -352,12 +353,19 @@ func TestEmbedded(t *testing.T) {
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
"Test\r\n" +
|
"Test\r\n" +
|
||||||
"--_BOUNDARY_1_\r\n" +
|
"--_BOUNDARY_1_\r\n" +
|
||||||
"Content-Type: image/jpeg; name=\"image.jpg\"\r\n" +
|
"Content-Type: image/jpeg; name=\"image1.jpg\"\r\n" +
|
||||||
"Content-Disposition: inline; filename=\"image.jpg\"\r\n" +
|
"Content-Disposition: inline; filename=\"image1.jpg\"\r\n" +
|
||||||
"Content-ID: <image.jpg>\r\n" +
|
"Content-ID: <image1.jpg>\r\n" +
|
||||||
"Content-Transfer-Encoding: base64\r\n" +
|
"Content-Transfer-Encoding: base64\r\n" +
|
||||||
"\r\n" +
|
"\r\n" +
|
||||||
base64.StdEncoding.EncodeToString([]byte("Content")) + "\r\n" +
|
base64.StdEncoding.EncodeToString([]byte("Content 1")) + "\r\n" +
|
||||||
|
"--_BOUNDARY_1_\r\n" +
|
||||||
|
"Content-Type: image/jpeg; name=\"image2.jpg\"\r\n" +
|
||||||
|
"Content-Disposition: inline; filename=\"image2.jpg\"\r\n" +
|
||||||
|
"Content-ID: <image2.jpg>\r\n" +
|
||||||
|
"Content-Transfer-Encoding: base64\r\n" +
|
||||||
|
"\r\n" +
|
||||||
|
base64.StdEncoding.EncodeToString([]byte("Content 2")) + "\r\n" +
|
||||||
"--_BOUNDARY_1_--\r\n",
|
"--_BOUNDARY_1_--\r\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue