mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-26 10:32:29 -07:00
smtp: add available godoc link
Merge from net/smtp/smtp.go Obtained from: 1d45a7ef560a76318ed59dfdb178cecd58caf948
This commit is contained in:
14
smtp.go
14
smtp.go
@@ -49,7 +49,7 @@ type Client struct {
|
|||||||
helloError error // the error from the hello
|
helloError error // the error from the hello
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
@@ -60,7 +60,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)
|
||||||
@@ -167,7 +167,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)
|
||||||
@@ -242,7 +242,7 @@ func (c *Client) Auth(a smtp.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
|
||||||
@@ -264,8 +264,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
|
||||||
@@ -288,7 +288,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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user