smtp

package
v0.0.0-...-acda5ee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

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

func AgnosticAuth(identity, username, password, host string) gosmtp.Auth

AgnosticAuth returns an Auth that match the correct authentication thanks to gosmtp.ServerInfo

func LoginAuth

func LoginAuth(username, password string) gosmtp.Auth

LoginAuth returns an Auth that implements the LOGIN authentication mechanism as defined in Internet-Draft draft-murchison-sasl-login-00. The LOGIN mechanism is still used by some SMTP server.

Types

type Service

type Service struct{}

func (Service) Category

func (s Service) Category() string

func (Service) Enabled

func (s Service) Enabled() bool

func (Service) Init

func (s Service) Init()

func (Service) Name

func (s Service) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL