mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-24 22:50:49 +01:00
Refactor variable names in client_120.go
Updated variable names in the client_120.go file to enhance readability and clarity. This observes best practices for naming conventions in Go, producing cleaner code that's easier to maintain and troubleshoot. Changes primarily consist of replacing abbreviations with full descriptive names.
This commit is contained in:
parent
d85c12220a
commit
40ea4fbfb3
1 changed files with 49 additions and 49 deletions
|
@ -13,30 +13,30 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Send sends out the mail message
|
// Send sends out the mail message
|
||||||
func (c *Client) Send(ml ...*Msg) (rerr error) {
|
func (c *Client) Send(messages ...*Msg) (returnErr error) {
|
||||||
if err := c.checkConn(); err != nil {
|
if err := c.checkConn(); err != nil {
|
||||||
rerr = &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)}
|
returnErr = &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, m := range ml {
|
for _, message := range messages {
|
||||||
m.sendError = nil
|
message.sendError = nil
|
||||||
if m.encoding == NoEncoding {
|
if message.encoding == NoEncoding {
|
||||||
if ok, _ := c.smtpClient.Extension("8BITMIME"); !ok {
|
if ok, _ := c.smtpClient.Extension("8BITMIME"); !ok {
|
||||||
m.sendError = &SendError{Reason: ErrNoUnencoded, isTemp: false}
|
message.sendError = &SendError{Reason: ErrNoUnencoded, isTemp: false}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f, err := m.GetSender(false)
|
from, err := message.GetSender(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.sendError = &SendError{Reason: ErrGetSender, errlist: []error{err}, isTemp: isTempError(err)}
|
message.sendError = &SendError{Reason: ErrGetSender, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
rl, err := m.GetRecipients()
|
rcpts, err := message.GetRecipients()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.sendError = &SendError{Reason: ErrGetRcpts, errlist: []error{err}, isTemp: isTempError(err)}
|
message.sendError = &SendError{Reason: ErrGetRcpts, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,65 +45,65 @@ func (c *Client) Send(ml ...*Msg) (rerr error) {
|
||||||
c.smtpClient.SetDSNMailReturnOption(string(c.dsnmrtype))
|
c.smtpClient.SetDSNMailReturnOption(string(c.dsnmrtype))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := c.smtpClient.Mail(f); err != nil {
|
if err = c.smtpClient.Mail(from); err != nil {
|
||||||
m.sendError = &SendError{Reason: ErrSMTPMailFrom, errlist: []error{err}, isTemp: isTempError(err)}
|
message.sendError = &SendError{Reason: ErrSMTPMailFrom, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
if reserr := c.smtpClient.Reset(); reserr != nil {
|
if resetSendErr := c.smtpClient.Reset(); resetSendErr != nil {
|
||||||
rerr = errors.Join(rerr, reserr)
|
returnErr = errors.Join(returnErr, resetSendErr)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
failed := false
|
failed := false
|
||||||
rse := &SendError{}
|
rcptSendErr := &SendError{}
|
||||||
rse.errlist = make([]error, 0)
|
rcptSendErr.errlist = make([]error, 0)
|
||||||
rse.rcpt = make([]string, 0)
|
rcptSendErr.rcpt = make([]string, 0)
|
||||||
rno := strings.Join(c.dsnrntype, ",")
|
rcptNotifyOpt := strings.Join(c.dsnrntype, ",")
|
||||||
c.smtpClient.SetDSNRcptNotifyOption(rno)
|
c.smtpClient.SetDSNRcptNotifyOption(rcptNotifyOpt)
|
||||||
for _, r := range rl {
|
for _, rcpt := range rcpts {
|
||||||
if err := c.smtpClient.Rcpt(r); err != nil {
|
if err = c.smtpClient.Rcpt(rcpt); err != nil {
|
||||||
rse.Reason = ErrSMTPRcptTo
|
rcptSendErr.Reason = ErrSMTPRcptTo
|
||||||
rse.errlist = append(rse.errlist, err)
|
rcptSendErr.errlist = append(rcptSendErr.errlist, err)
|
||||||
rse.rcpt = append(rse.rcpt, r)
|
rcptSendErr.rcpt = append(rcptSendErr.rcpt, rcpt)
|
||||||
rse.isTemp = isTempError(err)
|
rcptSendErr.isTemp = isTempError(err)
|
||||||
failed = true
|
failed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if failed {
|
if failed {
|
||||||
if reserr := c.smtpClient.Reset(); reserr != nil {
|
if resetSendErr := c.smtpClient.Reset(); resetSendErr != nil {
|
||||||
rerr = errors.Join(rerr, reserr)
|
returnErr = errors.Join(returnErr, resetSendErr)
|
||||||
}
|
}
|
||||||
m.sendError = rse
|
message.sendError = rcptSendErr
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
w, err := c.smtpClient.Data()
|
writer, err := c.smtpClient.Data()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.sendError = &SendError{Reason: ErrSMTPData, errlist: []error{err}, isTemp: isTempError(err)}
|
message.sendError = &SendError{Reason: ErrSMTPData, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, err = m.WriteTo(w)
|
_, err = message.WriteTo(writer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.sendError = &SendError{Reason: ErrWriteContent, errlist: []error{err}, isTemp: isTempError(err)}
|
message.sendError = &SendError{Reason: ErrWriteContent, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
m.isDelivered = true
|
message.isDelivered = true
|
||||||
|
|
||||||
if err := w.Close(); err != nil {
|
if err = writer.Close(); err != nil {
|
||||||
m.sendError = &SendError{Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err)}
|
message.sendError = &SendError{Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.Reset(); err != nil {
|
if err = c.Reset(); err != nil {
|
||||||
m.sendError = &SendError{Reason: ErrSMTPReset, errlist: []error{err}, isTemp: isTempError(err)}
|
message.sendError = &SendError{Reason: ErrSMTPReset, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := c.checkConn(); err != nil {
|
if err = c.checkConn(); err != nil {
|
||||||
m.sendError = &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)}
|
message.sendError = &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)}
|
||||||
rerr = errors.Join(rerr, m.sendError)
|
returnErr = errors.Join(returnErr, message.sendError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue