Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ func main() {

// also you can add body from []byte with SetBodyData, example:
// email.SetBodyData(mail.TextHTML, []byte(htmlBody))
// or alternative part
// email.AddAlternativeData(mail.TextHTML, []byte(htmlBody))

// add inline
email.Attach(&mail.File{FilePath: "/path/to/image.png", Name:"Gopher.png", Inline: true})
Expand Down
19 changes: 19 additions & 0 deletions email.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,25 @@ func (email *Email) AddAlternative(contentType contentType, body string) *Email
return email
}

// AddAlternativeData allows you to add alternative parts to the body
// of the email message. This is most commonly used to add an
// html version in addition to a plain text version that was
// already added with SetBody.
func (email *Email) AddAlternativeData(contentType contentType, body []byte) *Email {
if email.Error != nil {
return email
}

email.parts = append(email.parts,
part{
contentType: contentType.string(),
body: bytes.NewBuffer(body),
},
)

return email
}

// GetFrom returns the sender of the email, if any
func (email *Email) GetFrom() string {
from := email.returnPath
Expand Down