Documentation
¶
Overview ¶
Package email allows to send email messages. The package is used internally by the mail package.
Index ¶
- Constants
- type Attachment
- type Email
- func (e *Email) Attach(r io.Reader, filename string, contentType string) (*Attachment, error)
- func (e *Email) AttachFile(filename string) (*Attachment, error)
- func (e *Email) Bytes() ([]byte, error)
- func (e *Email) Send(address string, auth smtp.Auth, helo string) error
- func (e *Email) SendWithStartTLS(address string, auth smtp.Auth, config *tls.Config, helo string) error
- func (e *Email) SendWithTLS(address string, auth smtp.Auth, config *tls.Config, helo string) error
Constants ¶
const ( // MaxLineLength is the maximum line length per RFC 2045 MaxLineLength = 76 // DefaultContentType is the default Content-Type according to RFC 2045, section 5.2 DefaultContentType = "text/plain; charset=us-ascii" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
Filename string
ContentType string
Header textproto.MIMEHeader
Content []byte
HTMLRelated bool
}
Attachment is a struct representing an email attachment. Based on the mime/multipart.FileHeader struct, Attachment contains the name, MIMEHeader, and content of the attachment in question
type Email ¶
type Email struct {
ReplyTo []string
From string
To []string
Bcc []string
Cc []string
Subject string
Text []byte
HTML []byte
Sender string
Headers textproto.MIMEHeader
Attachments []*Attachment
ReadReceipt []string
}
Email is the type used for email messages
func NewFromReader ¶
NewFromReader reads a stream of bytes from an io.Reader, r, and returns an email struct containing the parsed data. This function expects the data in RFC 5322 format.
func (*Email) AttachFile ¶
func (e *Email) AttachFile(filename string) (*Attachment, error)
AttachFile is used to attach content to the email. It attempts to open the file referenced by filename and, if successful, creates an Attachment.
func (*Email) Bytes ¶
Bytes converts the Email object to a []byte representation, including all needed MIMEHeaders, boundaries, etc.
func (*Email) Send ¶
Send an email using the given host and SMTP auth (optional), returns any error thrown by smtp.SendMail This function merges the To, Cc, and Bcc fields and calls the smtp.SendMail function using the Email.Bytes() output as the message