|
@@ -311,11 +311,39 @@ func (m *Message) appendFile(list []*file, name string, settings []FileSetting)
|
|
return append(list, f)
|
|
return append(list, f)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (m *Message) appendFile_new(list []*file, fb []byte, settings []FileSetting) []*file {
|
|
|
|
+ f := &file{
|
|
|
|
+ Name: filepath.Base(""),
|
|
|
|
+ Header: make(map[string][]string),
|
|
|
|
+ CopyFunc: func(w io.Writer) error {
|
|
|
|
+ h := bytes.NewReader(fb)
|
|
|
|
+ if _, err := io.Copy(w, h); err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, s := range settings {
|
|
|
|
+ s(f)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if list == nil {
|
|
|
|
+ return []*file{f}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return append(list, f)
|
|
|
|
+}
|
|
|
|
+
|
|
// Attach attaches the files to the email.
|
|
// Attach attaches the files to the email.
|
|
func (m *Message) Attach(filename string, settings ...FileSetting) {
|
|
func (m *Message) Attach(filename string, settings ...FileSetting) {
|
|
m.attachments = m.appendFile(m.attachments, filename, settings)
|
|
m.attachments = m.appendFile(m.attachments, filename, settings)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (m *Message) Attach_new(fb []byte, settings ...FileSetting) {
|
|
|
|
+ m.attachments = m.appendFile_new(m.attachments, fb, settings)
|
|
|
|
+}
|
|
|
|
+
|
|
// Embed embeds the images to the email.
|
|
// Embed embeds the images to the email.
|
|
func (m *Message) Embed(filename string, settings ...FileSetting) {
|
|
func (m *Message) Embed(filename string, settings ...FileSetting) {
|
|
m.embedded = m.appendFile(m.embedded, filename, settings)
|
|
m.embedded = m.appendFile(m.embedded, filename, settings)
|