2023-01-10 10:09:45 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2010 The Go Authors. All rights reserved.
|
|
|
|
// SPDX-FileCopyrightText: Copyright (c) 2022-2023 The go-mail Authors
|
|
|
|
//
|
|
|
|
// Original net/smtp code from the Go stdlib by the Go Authors.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
2023-01-13 16:54:55 +01:00
|
|
|
// LICENSE file that can be found in this directory.
|
2023-01-10 10:09:45 +01:00
|
|
|
//
|
|
|
|
// go-mail specific modifications by the go-mail Authors.
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
// See [PROJECT ROOT]/LICENSES directory for more information.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause AND MIT
|
|
|
|
|
2023-01-10 00:38:42 +01:00
|
|
|
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"
|
|
|
|
}
|