forked from xhit/go-simple-mail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attach_old.go
69 lines (56 loc) · 2.44 KB
/
attach_old.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package mail
import (
"errors"
)
// TODO: Remove this file before launch v3
// AddAttachment. DEPRECATED. Use Attach method. Allows you to add an attachment to the email message.
// You can optionally provide a different name for the file.
func (email *Email) AddAttachment(file string, name ...string) *Email {
if email.Error != nil {
return email
}
if len(name) > 1 {
email.Error = errors.New("Mail Error: Attach can only have a file and an optional name")
return email
}
var nm string
if len(name) == 1 {
nm = name[0]
}
return email.Attach(&File{Name: nm, FilePath: file})
}
// AddAttachmentData. DEPRECATED. Use Attach method. Allows you to add an in-memory attachment to the email message.
func (email *Email) AddAttachmentData(data []byte, filename, mimeType string) *Email {
return email.Attach(&File{Data: data, Name: filename, MimeType: mimeType})
}
// AddAttachmentBase64. DEPRECATED. Use Attach method. Allows you to add an attachment in base64 to the email message.
// You need provide a name for the file.
func (email *Email) AddAttachmentBase64(b64File, name string) *Email {
return email.Attach(&File{B64Data: b64File, Name: name})
}
// AddInline. DEPRECATED. Use Attach method. Allows you to add an inline attachment to the email message.
// You can optionally provide a different name for the file.
func (email *Email) AddInline(file string, name ...string) *Email {
if email.Error != nil {
return email
}
if len(name) > 1 {
email.Error = errors.New("Mail Error: Inline can only have a file and an optional name")
return email
}
var nm string
if len(name) == 1 {
nm = name[0]
}
return email.Attach(&File{Name: nm, FilePath: file, Inline: true})
}
// AddInlineData. DEPRECATED. Use Attach method. Allows you to add an inline in-memory attachment to the email message.
func (email *Email) AddInlineData(data []byte, filename, mimeType string) *Email {
return email.Attach(&File{Data: data, Name: filename, MimeType: mimeType, Inline: true})
}
// AddInlineBase64. DEPRECATED. Use Attach method. Allows you to add an inline in-memory base64 encoded attachment to the email message.
// You need provide a name for the file. If mimeType is an empty string, attachment mime type will be deduced
// from the file name extension and defaults to application/octet-stream.
func (email *Email) AddInlineBase64(b64File, name, mimeType string) *Email {
return email.Attach(&File{B64Data: b64File, Name: name, MimeType: mimeType, Inline: true})
}