|
@@ -4,6 +4,7 @@ package email
|
|
|
|
|
|
import (
|
|
import (
|
|
"bytes"
|
|
"bytes"
|
|
|
|
+ "fmt"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"log"
|
|
"log"
|
|
"mime"
|
|
"mime"
|
|
@@ -49,14 +50,16 @@ func (e *Email) Attach(filename string) (a *Attachment, err error) {
|
|
Filename: filename,
|
|
Filename: filename,
|
|
Header: make(textproto.MIMEHeader),
|
|
Header: make(textproto.MIMEHeader),
|
|
Content: buffer}
|
|
Content: buffer}
|
|
|
|
+ at := e.Attachments[filename]
|
|
//Get the Content-Type to be used in the MIMEHeader
|
|
//Get the Content-Type to be used in the MIMEHeader
|
|
ct := mime.TypeByExtension(filepath.Ext(filename))
|
|
ct := mime.TypeByExtension(filepath.Ext(filename))
|
|
if ct != "" {
|
|
if ct != "" {
|
|
- e.Attachments[filename].Header.Set("Content-Type", ct)
|
|
|
|
|
|
+ at.Header.Set("Content-Type", ct)
|
|
} else {
|
|
} else {
|
|
//If the Content-Type is blank, set the Content-Type to "application/octet-stream"
|
|
//If the Content-Type is blank, set the Content-Type to "application/octet-stream"
|
|
- e.Attachments[filename].Header.Set("Content-Type", "application/octet-stream")
|
|
|
|
|
|
+ at.Header.Set("Content-Type", "application/octet-stream")
|
|
}
|
|
}
|
|
|
|
+ at.Header.Set("Content-Disposition", fmt.Sprintf("attachment;\r\n filename=%s", filename))
|
|
return e.Attachments[filename], nil
|
|
return e.Attachments[filename], nil
|
|
}
|
|
}
|
|
|
|
|