Refactor Client struct for better readability and organization

Reordered and grouped fields in the Client struct for clarity. The reorganization separates logical groups of fields, making it easier to understand and maintain the code. This includes proper grouping of TLS parameters, DSN options, and debug settings.
This commit is contained in:
Winni Neessen 2024-09-27 10:33:19 +02:00
parent b2c4b533d7
commit 371b950bc7
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -37,28 +37,45 @@ import (
// A Client represents a client connection to an SMTP server. // A Client represents a client connection to an SMTP server.
type Client struct { type Client struct {
// Text is the textproto.Conn used by the Client. It is exported to allow for // Text is the textproto.Conn used by the Client. It is exported to allow for clients to add extensions.
// clients to add extensions.
Text *textproto.Conn Text *textproto.Conn
// keep a reference to the connection so it can be used to create a TLS
// connection later // auth supported auth mechanisms
auth []string
// keep a reference to the connection so it can be used to create a TLS connection later
conn net.Conn conn net.Conn
// whether the Client is using TLS
tls bool // debug logging is enabled
serverName string debug bool
// map of supported extensions
// didHello indicates whether we've said HELO/EHLO
didHello bool
// dsnmrtype defines the mail return option in case DSN is enabled
dsnmrtype string
// dsnrntype defines the recipient notify option in case DSN is enabled
dsnrntype string
// ext is a map of supported extensions
ext map[string]string ext map[string]string
// supported auth mechanisms
auth []string // helloError is the error from the hello
localName string // the name to use in HELO/EHLO helloError error
didHello bool // whether we've said HELO/EHLO
helloError error // the error from the hello // localName is the name to use in HELO/EHLO
// debug logging localName string // the name to use in HELO/EHLO
debug bool // debug logging is enabled
logger log.Logger // logger will be used for debug logging // logger will be used for debug logging
// DSN support logger log.Logger
dsnmrtype string // dsnmrtype defines the mail return option in case DSN is enabled
dsnrntype string // dsnrntype defines the recipient notify option in case DSN is enabled // tls indicates whether the Client is using TLS
tls bool
// serverName denotes the name of the server to which the application will connect. Used for
// identification and routing.
serverName string
} }
// Dial returns a new [Client] connected to an SMTP server at addr. // Dial returns a new [Client] connected to an SMTP server at addr.