Documentation ¶
Overview ¶
Package email allows to send emails with attachments.
With base in scorredoira project (c) 2020 2ww Engenharia de Sistemas wilson.souza
Example ¶
// compose the message message := email.CreateMessage("Hi", "this is the body", email.EmailHtml) message.From = mail.Address{Name: "From", Address: "from@example.com"} message.AddTo(mail.Address{Name: "someToName", Address: "to@example.com"}) message.AddCc(mail.Address{Name: "someCcName", Address: "cc@example.com"}) message.AddBcc(mail.Address{Name: "someBccName", Address: "bcc@example.com"}) // add attachments failure := message.Attach("email.go") // if failure != nil { log.Fatal(err) } // add headers message.AddHeader("X-CUSTOMER-id", "HTML-Email-Formatted") // send it authentication := smtp.PlainAuth("", "wilson@example.com", "pwd", "smtp.zolla.com") failure := email.Send("smtp.zolla.com:587", authentication, message) // if failure != nil { log.Fatal(err) }
Output:
Index ¶
- Constants
- func Send(address string, authentication smtp.Auth, message *Message) error
- type Attachment
- type Header
- type Message
- func (m *Message) AddBcc(address mail.Address) []string
- func (m *Message) AddCc(address mail.Address) []string
- func (m *Message) AddHeader(key string, value string) Header
- func (m *Message) AddTo(address mail.Address) []string
- func (m *Message) Attach(file string, inline bool) error
- func (m *Message) AttachBuffer(filename string, buf []byte, inline bool) error
- func (m *Message) Inline(file string) error
- func (m *Message) ToBytes() []byte
- func (m *Message) ToList() []string
Examples ¶
Constants ¶
View Source
const ( EmailTextType = "text/plain" EmailHTMLType = "text/html" )
define email body
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attachment ¶
Attachment represents an email attachment.
type Message ¶
type Message struct { From mail.Address To []string Cc []string Bcc []string ReplyTo string Subject string Body string BodyContentType string Headers []Header Attachments map[string]*Attachment }
Message represents a smtp message.
func CreateMessage ¶
func (*Message) AttachBuffer ¶
AttachBuffer attaches a binary attachment.
Click to show internal directories.
Click to hide internal directories.