package smtp

Import Path
	net/smtp (on golang.org and go.dev)

Dependency Relation
	imports 10 packages, and imported by 0 packages

Involved Source Files
	    auth.go
	d-> smtp.go

Exported Type Names

type Auth (interface) Auth is implemented by an SMTP authentication mechanism. (T) Next(fromServer []byte, more bool) (toServer []byte, err error) (T) Start(server *ServerInfo) (proto string, toServer []byte, err error) func CRAMMD5Auth(username, secret string) Auth func PlainAuth(identity, username, password, host string) Auth func SendMail(addr string, a Auth, from string, to []string, msg []byte) error func (*Client).Auth(a Auth) error
type Client (struct) A Client represents a client connection to an SMTP server. Text *textproto.Conn (*T) Auth(a Auth) error (*T) Close() error (*T) Data() (io.WriteCloser, error) (*T) Extension(ext string) (bool, string) (*T) Hello(localName string) error (*T) Mail(from string) error (*T) Noop() error (*T) Quit() error (*T) Rcpt(to string) error (*T) Reset() error (*T) StartTLS(config *tls.Config) error (*T) TLSConnectionState() (state tls.ConnectionState, ok bool) (*T) Verify(addr string) error *T : io.Closer func Dial(addr string) (*Client, error) func NewClient(conn net.Conn, host string) (*Client, error)
type ServerInfo (struct) ServerInfo records information about an SMTP server. Auth []string Name string TLS bool func Auth.Start(server *ServerInfo) (proto string, toServer []byte, err error)
Exported Values
func CRAMMD5Auth(username, secret string) Auth CRAMMD5Auth returns an Auth that implements the CRAM-MD5 authentication mechanism as defined in RFC 2195. The returned Auth uses the given username and secret to authenticate to the server using the challenge-response mechanism.
func Dial(addr string) (*Client, error) Dial returns a new Client connected to an SMTP server at addr. The addr must include a port, as in "mail.example.com:smtp".
func NewClient(conn net.Conn, host string) (*Client, error) NewClient returns a new Client using an existing connection and host as a server name to be used when authenticating.
func PlainAuth(identity, username, password, host string) Auth PlainAuth returns an Auth that implements the PLAIN authentication mechanism as defined in RFC 4616. The returned Auth uses the given username and password to authenticate to host and act as identity. Usually identity should be the empty string, to act as username. PlainAuth will only send the credentials if the connection is using TLS or is connected to localhost. Otherwise authentication will fail with an error, without sending the credentials.
func SendMail(addr string, a Auth, from string, to []string, msg []byte) error SendMail connects to the server at addr, switches to TLS if possible, authenticates with the optional mechanism a if possible, and then sends an email from address from, to addresses to, with message msg. The addr must include a port, as in "mail.example.com:smtp". The addresses in the to parameter are the SMTP RCPT addresses. The msg parameter should be an RFC 822-style email with headers first, a blank line, and then the message body. The lines of msg should be CRLF terminated. The msg headers should usually include fields such as "From", "To", "Subject", and "Cc". Sending "Bcc" messages is accomplished by including an email address in the to parameter but not including it in the msg headers. The SendMail function and the net/smtp package are low-level mechanisms and provide no support for DKIM signing, MIME attachments (see the mime/multipart package), or other mail functionality. Higher-level packages exist outside of the standard library.