mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-23 14:10:50 +01:00
Lock sendMutex to ensure thread safety in Send
Added a mutex lock and unlock around the Send function to prevent concurrent access issues and ensure thread safety. This change helps avoid race conditions when multiple goroutines attempt to send messages simultaneously.
This commit is contained in:
parent
be4201b05a
commit
3e504e6338
1 changed files with 2 additions and 0 deletions
|
@ -29,6 +29,8 @@ import (
|
|||
// Returns:
|
||||
// - An error that aggregates any SendErrors encountered during the sending process; otherwise, returns nil.
|
||||
func (c *Client) Send(messages ...*Msg) (returnErr error) {
|
||||
c.sendMutex.Lock()
|
||||
defer c.sendMutex.Unlock()
|
||||
return c.SendWithSMTPClient(c.smtpClient, messages...)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue