From f5437632f486b7d0a0a181c58f113c86d032b02c Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 24 Apr 2017 20:11:36 -0400 Subject: Upgrading server dependancies (#6215) --- vendor/gopkg.in/gomail.v2/send.go | 117 -------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 vendor/gopkg.in/gomail.v2/send.go (limited to 'vendor/gopkg.in/gomail.v2/send.go') diff --git a/vendor/gopkg.in/gomail.v2/send.go b/vendor/gopkg.in/gomail.v2/send.go deleted file mode 100644 index 3e6726509..000000000 --- a/vendor/gopkg.in/gomail.v2/send.go +++ /dev/null @@ -1,117 +0,0 @@ -package gomail - -import ( - "errors" - "fmt" - "io" - "net/mail" -) - -// Sender is the interface that wraps the Send method. -// -// Send sends an email to the given addresses. -type Sender interface { - Send(from string, to []string, msg io.WriterTo) error -} - -// SendCloser is the interface that groups the Send and Close methods. -type SendCloser interface { - Sender - Close() error -} - -// A SendFunc is a function that sends emails to the given adresses. -// -// The SendFunc type is an adapter to allow the use of ordinary functions as -// email senders. If f is a function with the appropriate signature, SendFunc(f) -// is a Sender object that calls f. -type SendFunc func(from string, to []string, msg io.WriterTo) error - -// Send calls f(from, to, msg). -func (f SendFunc) Send(from string, to []string, msg io.WriterTo) error { - return f(from, to, msg) -} - -// Send sends emails using the given Sender. -func Send(s Sender, msg ...*Message) error { - for i, m := range msg { - if err := send(s, m); err != nil { - return fmt.Errorf("gomail: could not send email %d: %v", i+1, err) - } - } - - return nil -} - -func send(s Sender, m *Message) error { - from, err := m.getFrom() - if err != nil { - return err - } - - to, err := m.getRecipients() - if err != nil { - return err - } - - if err := s.Send(from, to, m); err != nil { - return err - } - - return nil -} - -func (m *Message) getFrom() (string, error) { - from := m.header["Sender"] - if len(from) == 0 { - from = m.header["From"] - if len(from) == 0 { - return "", errors.New(`gomail: invalid message, "From" field is absent`) - } - } - - return parseAddress(from[0]) -} - -func (m *Message) getRecipients() ([]string, error) { - n := 0 - for _, field := range []string{"To", "Cc", "Bcc"} { - if addresses, ok := m.header[field]; ok { - n += len(addresses) - } - } - list := make([]string, 0, n) - - for _, field := range []string{"To", "Cc", "Bcc"} { - if addresses, ok := m.header[field]; ok { - for _, a := range addresses { - addr, err := parseAddress(a) - if err != nil { - return nil, err - } - list = addAddress(list, addr) - } - } - } - - return list, nil -} - -func addAddress(list []string, addr string) []string { - for _, a := range list { - if addr == a { - return list - } - } - - return append(list, addr) -} - -func parseAddress(field string) (string, error) { - a, err := mail.ParseAddress(field) - if a == nil { - return "", err - } - - return a.Address, err -} -- cgit v1.2.3-1-g7c22