Merge pull request #165 from wneessen/sync-net-smtp-upstream

Upstream sync / refine function comments to include return type GoDoc links
This commit is contained in:
Winni Neessen 2024-01-10 11:06:57 +01:00 committed by GitHub
commit e4927fde82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 11 deletions

View file

@ -27,7 +27,7 @@ type cramMD5Auth struct {
username, secret string username, secret string
} }
// CRAMMD5Auth returns an Auth that implements the CRAM-MD5 authentication // CRAMMD5Auth returns an [Auth] that implements the CRAM-MD5 authentication
// mechanism as defined in RFC 2195. // mechanism as defined in RFC 2195.
// The returned Auth uses the given username and secret to authenticate // The returned Auth uses the given username and secret to authenticate
// to the server using the challenge-response mechanism. // to the server using the challenge-response mechanism.

View file

@ -27,7 +27,7 @@ type cramMD5Auth struct {
username, secret string username, secret string
} }
// CRAMMD5Auth returns an Auth that implements the CRAM-MD5 authentication // CRAMMD5Auth returns an [Auth] that implements the CRAM-MD5 authentication
// mechanism as defined in RFC 2195. // mechanism as defined in RFC 2195.
// The returned Auth uses the given username and secret to authenticate // The returned Auth uses the given username and secret to authenticate
// to the server using the challenge-response mechanism. // to the server using the challenge-response mechanism.

View file

@ -43,7 +43,7 @@ const (
LoginXDraftPasswordChallenge = "Password\x00" LoginXDraftPasswordChallenge = "Password\x00"
) )
// LoginAuth returns an Auth that implements the LOGIN authentication // LoginAuth returns an [Auth] that implements the LOGIN authentication
// mechanism as it is used by MS Outlook. The Auth works similar to PLAIN // mechanism as it is used by MS Outlook. The Auth works similar to PLAIN
// but instead of sending all in one response, the login is handled within // but instead of sending all in one response, the login is handled within
// 3 steps: // 3 steps:

View file

@ -23,7 +23,7 @@ type plainAuth struct {
host string host string
} }
// PlainAuth returns an Auth that implements the PLAIN authentication // PlainAuth returns an [Auth] that implements the PLAIN authentication
// mechanism as defined in RFC 4616. The returned Auth uses the given // mechanism as defined in RFC 4616. The returned Auth uses the given
// username and password to authenticate to host and act as identity. // username and password to authenticate to host and act as identity.
// Usually identity should be the empty string, to act as username. // Usually identity should be the empty string, to act as username.

View file

@ -8,6 +8,11 @@ type xoauth2Auth struct {
username, token string username, token string
} }
// XOAuth2Auth returns an [Auth] that implements the XOAuth2 authentication
// mechanism as defined in the following specs:
//
// https://developers.google.com/gmail/imap/xoauth2-protocol
// https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
func XOAuth2Auth(username, token string) Auth { func XOAuth2Auth(username, token string) Auth {
return &xoauth2Auth{username, token} return &xoauth2Auth{username, token}
} }

View file

@ -60,7 +60,7 @@ type Client struct {
dsnrntype string // dsnrntype defines the recipient notify option in case DSN is enabled dsnrntype string // dsnrntype defines the recipient notify option in case DSN is enabled
} }
// Dial returns a new Client connected to an SMTP server at addr. // Dial returns a new [Client] connected to an SMTP server at addr.
// The addr must include a port, as in "mail.example.com:smtp". // The addr must include a port, as in "mail.example.com:smtp".
func Dial(addr string) (*Client, error) { func Dial(addr string) (*Client, error) {
conn, err := net.Dial("tcp", addr) conn, err := net.Dial("tcp", addr)
@ -71,7 +71,7 @@ func Dial(addr string) (*Client, error) {
return NewClient(conn, host) return NewClient(conn, host)
} }
// NewClient returns a new Client using an existing connection and host as a // NewClient returns a new [Client] using an existing connection and host as a
// server name to be used when authenticating. // server name to be used when authenticating.
func NewClient(conn net.Conn, host string) (*Client, error) { func NewClient(conn net.Conn, host string) (*Client, error) {
text := textproto.NewConn(conn) text := textproto.NewConn(conn)
@ -164,7 +164,7 @@ func (c *Client) StartTLS(config *tls.Config) error {
} }
// TLSConnectionState returns the client's TLS connection state. // TLSConnectionState returns the client's TLS connection state.
// The return values are their zero values if StartTLS did // The return values are their zero values if [Client.StartTLS] did
// not succeed. // not succeed.
func (c *Client) TLSConnectionState() (state tls.ConnectionState, ok bool) { func (c *Client) TLSConnectionState() (state tls.ConnectionState, ok bool) {
tc, ok := c.conn.(*tls.Conn) tc, ok := c.conn.(*tls.Conn)
@ -247,7 +247,7 @@ func (c *Client) Auth(a Auth) error {
// If the server supports the 8BITMIME extension, Mail adds the BODY=8BITMIME // If the server supports the 8BITMIME extension, Mail adds the BODY=8BITMIME
// parameter. If the server supports the SMTPUTF8 extension, Mail adds the // parameter. If the server supports the SMTPUTF8 extension, Mail adds the
// SMTPUTF8 parameter. // SMTPUTF8 parameter.
// This initiates a mail transaction and is followed by one or more Rcpt calls. // This initiates a mail transaction and is followed by one or more [Client.Rcpt] calls.
func (c *Client) Mail(from string) error { func (c *Client) Mail(from string) error {
if err := validateLine(from); err != nil { if err := validateLine(from); err != nil {
return err return err
@ -273,8 +273,8 @@ func (c *Client) Mail(from string) error {
} }
// Rcpt issues a RCPT command to the server using the provided email address. // Rcpt issues a RCPT command to the server using the provided email address.
// A call to Rcpt must be preceded by a call to Mail and may be followed by // A call to Rcpt must be preceded by a call to [Client.Mail] and may be followed by
// a Data call or another Rcpt call. // a [Client.Data] call or another Rcpt call.
func (c *Client) Rcpt(to string) error { func (c *Client) Rcpt(to string) error {
if err := validateLine(to); err != nil { if err := validateLine(to); err != nil {
return err return err
@ -302,7 +302,7 @@ func (d *dataCloser) Close() error {
// Data issues a DATA command to the server and returns a writer that // Data issues a DATA command to the server and returns a writer that
// can be used to write the mail headers and body. The caller should // can be used to write the mail headers and body. The caller should
// close the writer before calling any more methods on c. A call to // close the writer before calling any more methods on c. A call to
// Data must be preceded by one or more calls to Rcpt. // Data must be preceded by one or more calls to [Client.Rcpt].
func (c *Client) Data() (io.WriteCloser, error) { func (c *Client) Data() (io.WriteCloser, error) {
_, _, err := c.cmd(354, "DATA") _, _, err := c.cmd(354, "DATA")
if err != nil { if err != nil {