Attach is used to attach content from an io.Reader to the email. Required parameters include an io.Reader, the desired filename for the attachment, and the Content-Type The function will return the created Attachment for reference, as well as nil for the error, if successful.
ct := mime.TypeByExtension(filepath.Ext(filename)) basename := filepath.Base(filename) return e.Attach(f, basename, ct) }
e.Text = byte("Text Body is, of course, supported!\n") e.HTML = byte("
Fancy Html is supported, too!\n") e.Attach(bytes.NewBufferString("Rad attachement"), "rad.txt", "text/plain; charset=utf-8") raw, err := e.Bytes()