2023-01-15 16:14:19 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022-2023 The go-mail Authors
|
2022-12-10 13:41:00 +01:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
//go:build go1.20
|
|
|
|
// +build go1.20
|
|
|
|
|
|
|
|
package mail
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Send sends out the mail message
|
2024-02-27 11:14:33 +01:00
|
|
|
func (c *Client) Send(messages ...*Msg) (returnErr error) {
|
2022-12-10 13:41:00 +01:00
|
|
|
if err := c.checkConn(); err != nil {
|
2024-02-27 11:14:33 +01:00
|
|
|
returnErr = &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)}
|
2022-12-10 13:41:00 +01:00
|
|
|
return
|
|
|
|
}
|
2024-07-16 13:07:20 +02:00
|
|
|
|
|
|
|
var errs []error
|
|
|
|
defer func() {
|
|
|
|
returnErr = errors.Join(errs...)
|
|
|
|
}()
|
|
|
|
|
2024-09-18 12:29:42 +02:00
|
|
|
for id, message := range messages {
|
2024-09-18 11:06:48 +02:00
|
|
|
if sendErr := c.sendSingleMsg(message); sendErr != nil {
|
2024-09-18 12:29:42 +02:00
|
|
|
messages[id].sendError = sendErr
|
2024-09-18 11:06:48 +02:00
|
|
|
errs = append(errs, sendErr)
|
2022-12-10 13:41:00 +01:00
|
|
|
}
|
2024-09-18 11:06:48 +02:00
|
|
|
}
|
2022-12-10 13:41:00 +01:00
|
|
|
|
2024-09-18 11:06:48 +02:00
|
|
|
return
|
|
|
|
}
|