mirror of
https://github.com/wneessen/go-mail.git
synced 2024-09-19 18:52:47 +02:00
32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
|
package smtp
|
||
|
|
||
|
// Auth is implemented by an SMTP authentication mechanism.
|
||
|
type Auth interface {
|
||
|
// Start begins an authentication with a server.
|
||
|
// It returns the name of the authentication protocol
|
||
|
// and optionally data to include in the initial AUTH message
|
||
|
// sent to the server.
|
||
|
// If it returns a non-nil error, the SMTP client aborts
|
||
|
// the authentication attempt and closes the connection.
|
||
|
Start(server *ServerInfo) (proto string, toServer []byte, err error)
|
||
|
|
||
|
// Next continues the authentication. The server has just sent
|
||
|
// the fromServer data. If more is true, the server expects a
|
||
|
// response, which Next should return as toServer; otherwise
|
||
|
// Next should return toServer == nil.
|
||
|
// If Next returns a non-nil error, the SMTP client aborts
|
||
|
// the authentication attempt and closes the connection.
|
||
|
Next(fromServer []byte, more bool) (toServer []byte, err error)
|
||
|
}
|
||
|
|
||
|
// ServerInfo records information about an SMTP server.
|
||
|
type ServerInfo struct {
|
||
|
Name string // SMTP server name
|
||
|
TLS bool // using TLS, with valid certificate for Name
|
||
|
Auth []string // advertised authentication mechanisms
|
||
|
}
|
||
|
|
||
|
func isLocalhost(name string) bool {
|
||
|
return name == "localhost" || name == "127.0.0.1" || name == "::1"
|
||
|
}
|