Documentation
¶
Overview ¶
Package email is designed to provide an "email interface for humans." Designed to be robust and flexible, the email package aims to make sending email easy without getting in the way.
Index ¶
Constants ¶
const (
// MaxLineLength is the maximum line length per RFC 2045
MaxLineLength = 76
)
Variables ¶
This section is empty.
Functions ¶
func ReadConfig ¶
ReadConfig reads json file path and try to unmashal it to config
func SendSMTPWithoutAuth ¶
SendSMTPWithoutAuth sends email to specified smtpServer without trying to authenticate
Types ¶
type Attachment ¶
type Attachment struct { Filename string Header textproto.MIMEHeader Content []byte }
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 Config ¶
type Config struct { From string `json:"from"` SMTPUsername string `json:"smtp_username"` SMTPPassword string `json:"smtp_password"` Server string `json:"server"` Port int64 `json:port` }
Config Stores default values
type Email ¶
type Email struct { From string To []string Bcc []string Cc []string Subject string Text []byte // Plaintext message (optional) HTML []byte // Html message (optional) Headers textproto.MIMEHeader Attachments []*Attachment ReadReceipt []string }
Email is the type used for email messages
func NewEmail ¶
func NewEmail() *Email
NewEmail creates an Email, and returns the pointer to it. Default from to config's from is set.
func (*Email) Attach ¶
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.
func (*Email) AttachFile ¶
func (e *Email) AttachFile(filename string) (a *Attachment, err 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. This Attachment is then appended to the slice of Email.Attachments. The function will then return the Attachment for reference, as well as nil for the error, if successful.
func (*Email) Bytes ¶
Bytes converts the Email object to a []byte representation, including all needed MIMEHeaders, boundaries, etc.
func (*Email) SetMessage ¶
SetMessage adds string as email message