Documentation ¶
Overview ¶
Package mimemail implements functionality for creating MIME email messages
Example ¶
// let's assume that contains some image var logo []byte mixed := NewMultipart("multipart/mixed") html := mixed.NewDiscrete("text/html", "charset", "utf-8") html.Encoding(QuotedPrintable) html.Content([]byte(`<html><body> <img src="cid:logo.png"> <h1>Hi there!</h1></body></html>`)) img := mixed.NewDiscrete("image.png") img.Encoding(Base64) img.Header().Add("content-id", "logo.png") img.Content(logo) msg := NewMessage(mixed) msg.Header().Add("Subject", "mimemail is here") msg.Header().Add("From", "Sender <sender@example.com>") msg.Header().Add("To", "Rcpt <recipient@example.com>") w := bytes.NewBuffer(nil) // this could be instead // w, _ = smtpClient.Data() if err := msg.Write(w); err != nil { panic(err) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Discrete ¶
type Discrete struct {
// contains filtered or unexported fields
}
Discrete is a discret entity that contains a single piece of content of certain type
func NewDiscrete ¶
NewDiscrete returns a new Discrete object with given content type and content type parameters
func (*Discrete) Content ¶
Content sets the content of the entity. Content should be given as raw bytes, it will be encoded automatically by Write method.
func (*Discrete) Encoding ¶
Encoding sets the content transfer encoding. Write will encode content using the given method.
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header is the header of the email message or a MIME entity
type Message ¶
type Message struct {
Part
}
Message represent an email message
func NewMessage ¶
NewMessage creates a new email message based on the provided part
type Multipart ¶
type Multipart struct {
// contains filtered or unexported fields
}
Multipart is a composite entity that can contain multiple parts
func NewMultipart ¶
NewMultipart returns new Multipart object
func (*Multipart) NewDiscrete ¶
NewDiscrete returns a new Discrete object that is already added as a part to the parent object
func (*Multipart) NewMultipart ¶
NewMultipart returns a new Multipart object that is already added as a part to the parent object