Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Send = func(localName, serverAddress string, enableStartTLS bool, a gosmtp.Auth, from string, to []string, msg []byte) error { host, _, _ := net.SplitHostPort(serverAddress) c, err := gosmtp.Dial(serverAddress) if err != nil { return err } defer c.Close() if err = c.Hello(localName); err != nil { return err } if enableStartTLS { if ok, _ := c.Extension("STARTTLS"); ok { config := &tls.Config{ServerName: host} if err = c.StartTLS(config); err != nil { return err } } } if a != nil { if ok, _ := c.Extension("AUTH"); !ok { return errors.New("smtp: server doesn't support AUTH") } if err = c.Auth(a); err != nil { return err } } if err = c.Mail(from); err != nil { return err } for _, addr := range to { if err = c.Rcpt(addr); err != nil { return err } } w, err := c.Data() if err != nil { return err } _, err = w.Write(msg) if err != nil { return err } err = w.Close() if err != nil { return err } return c.Quit() }
Functions ¶
func AgnosticAuth ¶
AgnosticAuth returns an Auth that match the correct authentication thanks to gosmtp.ServerInfo
Types ¶
Click to show internal directories.
Click to hide internal directories.