mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Rename DSN type variable for clarity
Renamed the variable from `dsnrntype` to `dsnRcptNotifyType` to improve code readability and ensure clarity regarding its purpose. Also updated corresponding comments and test cases to reflect this change.
This commit is contained in:
parent
f7c12d412b
commit
aab04672f8
2 changed files with 22 additions and 18 deletions
22
client.go
22
client.go
|
@ -106,20 +106,24 @@ type (
|
||||||
// dialContextFunc is the DialContextFunc that is used by the Client to connect to the SMTP server.
|
// dialContextFunc is the DialContextFunc that is used by the Client to connect to the SMTP server.
|
||||||
dialContextFunc DialContextFunc
|
dialContextFunc DialContextFunc
|
||||||
|
|
||||||
// dsnReturnType defines the DSNMailReturnOption in case DSN is enabled
|
// dsnRcptNotifyType represents the different types of notifications for DSN (Delivery Status Notifications)
|
||||||
dsnReturnType DSNMailReturnOption
|
// receipts.
|
||||||
|
dsnRcptNotifyType []string
|
||||||
|
|
||||||
// dsnrntype defines the DSNRcptNotifyOption in case DSN is enabled
|
// dsnReturnType specifies the type of Delivery Status Notification (DSN) that should be requested for an
|
||||||
dsnrntype []string
|
// email.
|
||||||
|
dsnReturnType DSNMailReturnOption
|
||||||
|
|
||||||
// fallbackPort is used as an alternative port number in case the primary port is unavailable or
|
// fallbackPort is used as an alternative port number in case the primary port is unavailable or
|
||||||
// fails to bind.
|
// fails to bind.
|
||||||
|
//
|
||||||
|
// The fallbackPort is only used in combination with SetTLSPortPolicy and SetSSLPort correspondingly.
|
||||||
fallbackPort int
|
fallbackPort int
|
||||||
|
|
||||||
// HELO/EHLO string for the greeting the target SMTP server
|
// helo is the hostname used in the HELO/EHLO greeting, that is sent to the target SMTP server.
|
||||||
helo string
|
helo string
|
||||||
|
|
||||||
// Hostname of the target SMTP server to connect to
|
// host is the hostname of the SMTP server we are connecting to.
|
||||||
host string
|
host string
|
||||||
|
|
||||||
// isEncrypted indicates if a Client connection is encrypted or not
|
// isEncrypted indicates if a Client connection is encrypted or not
|
||||||
|
@ -399,7 +403,7 @@ func WithDSN() Option {
|
||||||
return func(c *Client) error {
|
return func(c *Client) error {
|
||||||
c.requestDSN = true
|
c.requestDSN = true
|
||||||
c.dsnReturnType = DSNMailReturnFull
|
c.dsnReturnType = DSNMailReturnFull
|
||||||
c.dsnrntype = []string{string(DSNRcptNotifyFailure), string(DSNRcptNotifySuccess)}
|
c.dsnRcptNotifyType = []string{string(DSNRcptNotifyFailure), string(DSNRcptNotifySuccess)}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,7 +456,7 @@ func WithDSNRcptNotifyType(opts ...DSNRcptNotifyOption) Option {
|
||||||
}
|
}
|
||||||
|
|
||||||
c.requestDSN = true
|
c.requestDSN = true
|
||||||
c.dsnrntype = rcptOpts
|
c.dsnRcptNotifyType = rcptOpts
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -892,7 +896,7 @@ func (c *Client) sendSingleMsg(message *Msg) error {
|
||||||
rcptSendErr := &SendError{affectedMsg: message}
|
rcptSendErr := &SendError{affectedMsg: message}
|
||||||
rcptSendErr.errlist = make([]error, 0)
|
rcptSendErr.errlist = make([]error, 0)
|
||||||
rcptSendErr.rcpt = make([]string, 0)
|
rcptSendErr.rcpt = make([]string, 0)
|
||||||
rcptNotifyOpt := strings.Join(c.dsnrntype, ",")
|
rcptNotifyOpt := strings.Join(c.dsnRcptNotifyType, ",")
|
||||||
c.smtpClient.SetDSNRcptNotifyOption(rcptNotifyOpt)
|
c.smtpClient.SetDSNRcptNotifyOption(rcptNotifyOpt)
|
||||||
for _, rcpt := range rcpts {
|
for _, rcpt := range rcpts {
|
||||||
if err = c.smtpClient.Rcpt(rcpt); err != nil {
|
if err = c.smtpClient.Rcpt(rcpt); err != nil {
|
||||||
|
|
|
@ -490,13 +490,13 @@ func TestWithDSN(t *testing.T) {
|
||||||
t.Errorf("WithDSN failed. c.dsnReturnType expected to be: %s, got: %s", DSNMailReturnFull,
|
t.Errorf("WithDSN failed. c.dsnReturnType expected to be: %s, got: %s", DSNMailReturnFull,
|
||||||
c.dsnReturnType)
|
c.dsnReturnType)
|
||||||
}
|
}
|
||||||
if c.dsnrntype[0] != string(DSNRcptNotifyFailure) {
|
if c.dsnRcptNotifyType[0] != string(DSNRcptNotifyFailure) {
|
||||||
t.Errorf("WithDSN failed. c.dsnrntype[0] expected to be: %s, got: %s", DSNRcptNotifyFailure,
|
t.Errorf("WithDSN failed. c.dsnRcptNotifyType[0] expected to be: %s, got: %s", DSNRcptNotifyFailure,
|
||||||
c.dsnrntype[0])
|
c.dsnRcptNotifyType[0])
|
||||||
}
|
}
|
||||||
if c.dsnrntype[1] != string(DSNRcptNotifySuccess) {
|
if c.dsnRcptNotifyType[1] != string(DSNRcptNotifySuccess) {
|
||||||
t.Errorf("WithDSN failed. c.dsnrntype[1] expected to be: %s, got: %s", DSNRcptNotifySuccess,
|
t.Errorf("WithDSN failed. c.dsnRcptNotifyType[1] expected to be: %s, got: %s", DSNRcptNotifySuccess,
|
||||||
c.dsnrntype[1])
|
c.dsnRcptNotifyType[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,11 +547,11 @@ func TestWithDSNRcptNotifyType(t *testing.T) {
|
||||||
t.Errorf("failed to create new client: %s", err)
|
t.Errorf("failed to create new client: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(c.dsnrntype) <= 0 && !tt.sf {
|
if len(c.dsnRcptNotifyType) <= 0 && !tt.sf {
|
||||||
t.Errorf("WithDSNRcptNotifyType failed. Expected at least one DSNRNType but got none")
|
t.Errorf("WithDSNRcptNotifyType failed. Expected at least one DSNRNType but got none")
|
||||||
}
|
}
|
||||||
if !tt.sf && c.dsnrntype[0] != tt.want {
|
if !tt.sf && c.dsnRcptNotifyType[0] != tt.want {
|
||||||
t.Errorf("WithDSNRcptNotifyType failed. Expected %s, got: %s", tt.want, c.dsnrntype[0])
|
t.Errorf("WithDSNRcptNotifyType failed. Expected %s, got: %s", tt.want, c.dsnRcptNotifyType[0])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue