Skip to content

Commit

Permalink
Allow to add inplace in-memory data
Browse files Browse the repository at this point in the history
  • Loading branch information
falconandy committed Dec 9, 2020
1 parent d1e7602 commit 4ca89c9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions email.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,28 @@ func (email *Email) AddInline(file string, name ...string) *Email {
return email
}

// AddInlineData allows you to add an inline bytes attachment to the email message.
func (email *Email) AddInlineData(data []byte, filename, mimeType string) *Email {
if email.Error != nil {
return email
}

if mimeType == "" {
mimeType = mime.TypeByExtension(filepath.Ext(filename))
if mimeType == "" {
mimeType = "application/octet-stream"
}
}

email.inlines = append(email.inlines, &file{
filename: filename,
mimeType: mimeType,
data: data,
})

return email
}

// attach does the low level attaching of the files
func (email *Email) attach(f string, inline bool, name ...string) error {
// Get the file data
Expand Down

0 comments on commit 4ca89c9

Please sign in to comment.