Compare commits

..

No commits in common. "d400379e2f09747484d21b0c2c1be7267a5e5d58" and "508a2f2a6c02ce4e72c14db7259fbe910769e183" have entirely different histories.

2 changed files with 16 additions and 39 deletions

View file

@ -798,17 +798,13 @@ func (c *Client) sendSingleMsg(message *Msg) error {
} }
from, err := message.GetSender(false) from, err := message.GetSender(false)
if err != nil { if err != nil {
return &SendError{ return &SendError{Reason: ErrGetSender, errlist: []error{err}, isTemp: isTempError(err),
Reason: ErrGetSender, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message}
affectedMsg: message,
}
} }
rcpts, err := message.GetRecipients() rcpts, err := message.GetRecipients()
if err != nil { if err != nil {
return &SendError{ return &SendError{Reason: ErrGetRcpts, errlist: []error{err}, isTemp: isTempError(err),
Reason: ErrGetRcpts, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message}
affectedMsg: message,
}
} }
if c.dsn { if c.dsn {
@ -817,10 +813,8 @@ func (c *Client) sendSingleMsg(message *Msg) error {
} }
} }
if err = c.smtpClient.Mail(from); err != nil { if err = c.smtpClient.Mail(from); err != nil {
retError := &SendError{ retError := &SendError{Reason: ErrSMTPMailFrom, errlist: []error{err}, isTemp: isTempError(err),
Reason: ErrSMTPMailFrom, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message}
affectedMsg: message,
}
if resetSendErr := c.smtpClient.Reset(); resetSendErr != nil { if resetSendErr := c.smtpClient.Reset(); resetSendErr != nil {
retError.errlist = append(retError.errlist, resetSendErr) retError.errlist = append(retError.errlist, resetSendErr)
} }
@ -849,38 +843,28 @@ func (c *Client) sendSingleMsg(message *Msg) error {
} }
writer, err := c.smtpClient.Data() writer, err := c.smtpClient.Data()
if err != nil { if err != nil {
return &SendError{ return &SendError{Reason: ErrSMTPData, errlist: []error{err}, isTemp: isTempError(err),
Reason: ErrSMTPData, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message}
affectedMsg: message,
}
} }
_, err = message.WriteTo(writer) _, err = message.WriteTo(writer)
if err != nil { if err != nil {
return &SendError{ return &SendError{Reason: ErrWriteContent, errlist: []error{err}, isTemp: isTempError(err),
Reason: ErrWriteContent, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message}
affectedMsg: message,
}
} }
message.isDelivered = true message.isDelivered = true
if err = writer.Close(); err != nil { if err = writer.Close(); err != nil {
return &SendError{ return &SendError{Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err),
Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message}
affectedMsg: message,
}
} }
if err = c.Reset(); err != nil { if err = c.Reset(); err != nil {
return &SendError{ return &SendError{Reason: ErrSMTPReset, errlist: []error{err}, isTemp: isTempError(err),
Reason: ErrSMTPReset, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message}
affectedMsg: message,
}
} }
if err = c.checkConn(); err != nil { if err = c.checkConn(); err != nil {
return &SendError{ return &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err),
Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message}
affectedMsg: message,
}
} }
return nil return nil
} }

View file

@ -83,13 +83,6 @@ func TestSendError_IsTemp(t *testing.T) {
} }
} }
func TestSendError_IsTempNil(t *testing.T) {
var se *SendError
if se.IsTemp() {
t.Error("expected false on nil-senderror")
}
}
// returnSendError is a helper method to retunr a SendError with a specific reason // returnSendError is a helper method to retunr a SendError with a specific reason
func returnSendError(r SendErrReason, t bool) error { func returnSendError(r SendErrReason, t bool) error {
return &SendError{Reason: r, isTemp: t} return &SendError{Reason: r, isTemp: t}