mirror of https://github.com/gophish/gophish
Adding "Content-ID" headers to attachments to help support possible embedded images. Addresses #251
parent
ad45915aa2
commit
dac581a7eb
|
@ -6,6 +6,7 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
|
@ -199,12 +200,13 @@ func processCampaign(c *models.Campaign) {
|
||||||
}
|
}
|
||||||
// Attach the files
|
// Attach the files
|
||||||
for _, a := range c.Template.Attachments {
|
for _, a := range c.Template.Attachments {
|
||||||
e.Attach(func(a models.Attachment) (string, gomail.FileSetting) {
|
e.Attach(func(a models.Attachment) (string, gomail.FileSetting, gomail.FileSetting) {
|
||||||
|
h := map[string][]string{"Content-ID": {fmt.Sprintf("<%s>", a.Name)}}
|
||||||
return a.Name, gomail.SetCopyFunc(func(w io.Writer) error {
|
return a.Name, gomail.SetCopyFunc(func(w io.Writer) error {
|
||||||
decoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(a.Content))
|
decoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(a.Content))
|
||||||
_, err = io.Copy(w, decoder)
|
_, err = io.Copy(w, decoder)
|
||||||
return err
|
return err
|
||||||
})
|
}), gomail.SetHeader(h)
|
||||||
}(a))
|
}(a))
|
||||||
}
|
}
|
||||||
Logger.Printf("Sending Email to %s\n", t.Email)
|
Logger.Printf("Sending Email to %s\n", t.Email)
|
||||||
|
|
Loading…
Reference in New Issue