mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 05:40:50 +01:00
Refactor error handling in message sending loop
Changed from range over messages to range with index to correctly update sendError field in the original messages slice. This prevents shadowing issues and ensures proper error logging for each message.
This commit is contained in:
parent
ee726487f1
commit
8ee37abca2
1 changed files with 2 additions and 2 deletions
|
@ -24,9 +24,9 @@ func (c *Client) Send(messages ...*Msg) (returnErr error) {
|
|||
returnErr = errors.Join(errs...)
|
||||
}()
|
||||
|
||||
for _, message := range messages {
|
||||
for id, message := range messages {
|
||||
if sendErr := c.sendSingleMsg(message); sendErr != nil {
|
||||
message.sendError = sendErr
|
||||
messages[id].sendError = sendErr
|
||||
errs = append(errs, sendErr)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue